module OData::Model::Persistence
The OData::Model::Persistence
module encapsulates all the functionality specifically needed for OData::Model
to persist data to and from the OData
gem.
Public Class Methods
new(attr_values = {})
click to toggle source
A simple initializer that just accepts a hash and sets any matching accessors with the supplied value
# File lib/odata/model/persistence.rb, line 15 def initialize(attr_values = {}) attr_values.each do |attr_name, value| begin send("#{attr_name.to_sym}=", value) rescue NoMethodError next end end end
Public Instance Methods
persisted?()
click to toggle source
Returns whether the current instance has been persisted. @return [Boolean]
# File lib/odata/model/persistence.rb, line 27 def persisted? if instance_variable_defined?(:@persisted) instance_variable_get(:@persisted) else instance_variable_set(:@persisted, false) instance_variable_get(:@persisted) end end
reload!()
click to toggle source
Reload the model from OData
# File lib/odata/model/persistence.rb, line 44 def reload! # TODO reload OData entity #reset_changes end
save()
click to toggle source
Save the current model.
# File lib/odata/model/persistence.rb, line 37 def save self.class.odata_service[odata_entity_set_name] << odata_entity instance_variable_set(:@persisted, true) unless odata_entity.any_errors? #changes_applied end