Class: Redtape::Populator::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/redtape/populator/abstract.rb

Direct Known Subclasses

HasMany, HasOne, Root

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Abstract

Returns a new instance of Abstract.



6
7
8
9
10
11
12
13
14
# File 'lib/redtape/populator/abstract.rb', line 6

def initialize(args = {})
  @model              = args[:model]
  @association_name   = args[:association_name]
  @pending_attributes = args[:attrs]
  @parent             = args[:parent]
  @data_mapper        = args[:data_mapper]
  @attr_whitelist     = args[:attr_whitelist]
  @whitelist_failures = []
end

Instance Attribute Details

#association_nameObject (readonly)

Returns the value of attribute association_name.



4
5
6
# File 'lib/redtape/populator/abstract.rb', line 4

def association_name
  @association_name
end

#attr_whitelistObject (readonly)

Returns the value of attribute attr_whitelist.



4
5
6
# File 'lib/redtape/populator/abstract.rb', line 4

def attr_whitelist
  @attr_whitelist
end

#data_mapperObject (readonly)

Returns the value of attribute data_mapper.



4
5
6
# File 'lib/redtape/populator/abstract.rb', line 4

def data_mapper
  @data_mapper
end

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'lib/redtape/populator/abstract.rb', line 4

def model
  @model
end

#parentObject (readonly)

Returns the value of attribute parent.



4
5
6
# File 'lib/redtape/populator/abstract.rb', line 4

def parent
  @parent
end

#pending_attributesObject (readonly)

Returns the value of attribute pending_attributes.



4
5
6
# File 'lib/redtape/populator/abstract.rb', line 4

def pending_attributes
  @pending_attributes
end

#whitelist_failuresObject (readonly)

Returns the value of attribute whitelist_failures.



4
5
6
# File 'lib/redtape/populator/abstract.rb', line 4

def whitelist_failures
  @whitelist_failures
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
# File 'lib/redtape/populator/abstract.rb', line 16

def call
  populate_model_attributes(model, pending_attributes)

  if model.new_record?
    assign_to_parent
  end
end