class ActiveLoader::YamlLoader
Attributes
raw_content[R]
Public Class Methods
new(raw_content)
click to toggle source
# File lib/active_loader/yaml_loader.rb, line 8 def initialize(raw_content) @raw_content = raw_content.to_s end
Public Instance Methods
call()
click to toggle source
# File lib/active_loader/yaml_loader.rb, line 12 def call ensure_correct_type(safe_load) end
Private Instance Methods
ensure_correct_type(loaded_content)
click to toggle source
# File lib/active_loader/yaml_loader.rb, line 30 def ensure_correct_type(loaded_content) return nil if loaded_content.to_s.empty? if loaded_content.is_a? Hash loaded_content else raise ActiveLoader::ParseError.new("Must be a hash.", loader_name: klass_name) end end
klass_name()
click to toggle source
# File lib/active_loader/yaml_loader.rb, line 26 def klass_name @_klass_name ||= self.class.to_s end
safe_load()
click to toggle source
# File lib/active_loader/yaml_loader.rb, line 20 def safe_load YAML.safe_load(raw_content) rescue Psych::Exception, Psych::SyntaxError => exception raise ActiveLoader::ParseError.new(exception.message, loader_name: klass_name) end