Module: Cosm::Base::InstanceMethods

Defined in:
lib/cosm-rb/base/instance_methods.rb

Instance Method Summary collapse

Instance Method Details

#to_cosmObject

Converts a model that extends Cosm::Base into it’s equivalent Cosm object

this can then be used to convert into xml, json or csv


7
8
9
10
11
12
13
# File 'lib/cosm-rb/base/instance_methods.rb', line 7

def to_cosm
  attributes = {}
  self.class.cosm_class::ALLOWED_KEYS.each do |key|
    attributes[key] = self.send(key) if self.respond_to?(key)
  end
  self.class.cosm_class.new(attributes.merge(custom_cosm_attributes))
end