Module: FunWith::Patterns::Loader::LoadingStyles::YAML

Defined in:
lib/fun_with/patterns/loader/loading_styles/yaml.rb

Instance Method Summary collapse

Instance Method Details

#loader_pattern_load_item(file) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fun_with/patterns/loader/loading_styles/yaml.rb', line 6

def loader_pattern_load_item( file )
  self.loader_pattern_rescue_failing_item_load( file ) do
    obj = self.new
    
    hash = Psych.load( file.read )
    
    for method, val in hash
      eq_method = :"#{method}="
      
      if obj.respond_to?( eq_method )
        obj.send( eq_method, val )
      end
    end
    
    return obj
  end
end