Module: Adify::Methods

Defined in:
lib/adify.rb

Instance Method Summary collapse

Instance Method Details

#adification(item = nil) ⇒ Object



30
31
32
33
34
# File 'lib/adify.rb', line 30

def adification(item = nil)
  ad_attr = item.nil? ? self.adify_attributes : self.adify_attributes.adify_merge(item.adify_attributes)
  item_for_adification = item.nil? ? self : item
  ad_attr.update_values{|v| get_adify_value(item_for_adification,v)}.symbolize_keys_recursively
end

#adify_attributesObject



24
25
26
27
28
# File 'lib/adify.rb', line 24

def adify_attributes
  my_attributes = @adify_attributes || {}
  merge_with = self.respond_to?(:ancestors) ? self.ancestors.slice(1,self.ancestors.length).select{|c| c.respond_to?(:adify_attributes)}.first : self.class
  merge_with.respond_to?(:adify_attributes) ? merge_with.adify_attributes.adify_merge(my_attributes) : my_attributes
end

#adify_attributes=(hash) ⇒ Object



20
21
22
# File 'lib/adify.rb', line 20

def adify_attributes=(hash)
  @adify_attributes = hash
end