Class: Simplifyapi::Importer

Inherits:
Object
  • Object
show all
Includes:
DSLMethods
Defined in:
lib/simplifyapi/importer.rb

Instance Method Summary collapse

Methods included from DSLMethods

#collection, #initialize, #method_missing, #property

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Simplifyapi::DSLMethods

Instance Method Details

#import(representer, model, hash) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/simplifyapi/importer.rb', line 5

def import representer, model, hash
  @store = {}
  @representer = representer
  @model = model

  # Registering keys and properties
  @block.call(self, @model) if @block

  # Then we play the score accordingly
  @store.each do |key, object|
    if object.is_a? Importer
      object.import representer, model, hash[key.to_s]
    else
      if hash && hash.has_key?(key) && object.respond_to?(:import)
        object.import model, hash[key]
      end
    end
  end

  hash
end