Class: Fakecrm::TypeExtender

Inherits:
Object
  • Object
show all
Defined in:
lib/fakecrm/resource/extensions/type_extender.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_type) ⇒ TypeExtender

Returns a new instance of TypeExtender.



14
15
16
# File 'lib/fakecrm/resource/extensions/type_extender.rb', line 14

def initialize(custom_type)
  self.custom_type = custom_type
end

Instance Attribute Details

#custom_typeObject

Returns the value of attribute custom_type.



39
40
41
# File 'lib/fakecrm/resource/extensions/type_extender.rb', line 39

def custom_type
  @custom_type
end

Instance Method Details

#extend!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fakecrm/resource/extensions/type_extender.rb', line 18

def extend!
  custom_attributes = self.custom_type.custom_attributes
  case self.custom_type.id
  when 'contact'
    TypeExtension.new(Contact).replace!(custom_attributes)
  when 'account'
    TypeExtension.new(Account).replace!(custom_attributes)
  else
    case self.custom_type.kind
    when 'Event'
      TypeExtension.new(Event).add!(custom_attributes)
    when 'Activity'
      TypeExtension.new(Activity).add!(custom_attributes)
    when 'EventContact'
      TypeExtension.new(EventContact).add!(custom_attributes)
    else
      true
    end
  end
end