Module: ZohoHub::WithAttributes::ClassMethods
- Defined in:
- lib/zoho_hub/with_attributes.rb
Instance Method Summary collapse
- #attr_to_zoho_key(attr_name) ⇒ Object
- #attribute_translation(translation = nil) ⇒ Object
- #attributes(*attributes) ⇒ Object
- #zoho_key_translation ⇒ Object
Instance Method Details
#attr_to_zoho_key(attr_name) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/zoho_hub/with_attributes.rb', line 46 def attr_to_zoho_key(attr_name) if attribute_translation.key?(attr_name.to_sym) return attribute_translation[attr_name.to_sym] end attr_name.to_s.split('_').map(&:capitalize).join('_').to_sym end |
#attribute_translation(translation = nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/zoho_hub/with_attributes.rb', line 38 def attribute_translation(translation = nil) @attribute_translation ||= {} return @attribute_translation unless translation @attribute_translation = translation end |
#attributes(*attributes) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/zoho_hub/with_attributes.rb', line 28 def attributes(*attributes) @attributes ||= [] return @attributes unless attributes attr_accessor(*attributes) @attributes += attributes end |
#zoho_key_translation ⇒ Object
54 55 56 |
# File 'lib/zoho_hub/with_attributes.rb', line 54 def zoho_key_translation @attribute_translation.to_a.map(&:rotate).to_h end |