Class: Zoro::Record
- Inherits:
-
Object
- Object
- Zoro::Record
- Defined in:
- lib/zoro/record.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#zoho_module ⇒ Object
readonly
Returns the value of attribute zoho_module.
Instance Method Summary collapse
- #api ⇒ Object
- #api=(api) ⇒ Object
-
#initialize(zoho_module = self.class.name) ⇒ Record
constructor
A new instance of Record.
- #method_missing(name, *args, &block) ⇒ Object
- #save! ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(zoho_module = self.class.name) ⇒ Record
Returns a new instance of Record.
5 6 7 8 |
# File 'lib/zoro/record.rb', line 5 def initialize(zoho_module= self.class.name) @zoho_module = zoho_module @fields = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/zoro/record.rb', line 33 def method_missing(name, *args, &block) property_name = Zoro::FieldName.make_field(name.to_s) assignment = name.to_s.match(/=/) if assignment set_field property_name, args[0] else get_field property_name end end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
3 4 5 |
# File 'lib/zoro/record.rb', line 3 def fields @fields end |
#zoho_module ⇒ Object (readonly)
Returns the value of attribute zoho_module.
3 4 5 |
# File 'lib/zoro/record.rb', line 3 def zoho_module @zoho_module end |
Instance Method Details
#api=(api) ⇒ Object
10 11 12 |
# File 'lib/zoro/record.rb', line 10 def api=(api) @api = api end |
#save! ⇒ Object
18 19 20 |
# File 'lib/zoro/record.rb', line 18 def save! api.insert_records(self) end |
#to_xml ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zoro/record.rb', line 22 def to_xml xml_map = Hash.new xml_map['row'] = { 'no' => '1', 'FL' => @fields.map do |k, v| { 'val' => k, 'content' => v} end } XmlSimple.xml_out(xml_map, :RootName => @zoho_module) end |