Class: Mirakl::MiraklObject

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mirakl/mirakl_object.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMiraklObject

def initialize(id = nil, opts = {})

id, @retrieve_params = Util.normalize_id(id)
@opts = Util.normalize_opts(opts)
@original_values = {}
@values = {}
# This really belongs in APIResource, but not putting it there allows us
# to have a unified inspect method
@unsaved_values = Set.new
@transient_values = Set.new
@values[:id] = id if id

end



19
20
21
# File 'lib/mirakl/mirakl_object.rb', line 19

def initialize
  @values = {}
end

Class Method Details

.construct_from(values, opts = {}) ⇒ Object



29
30
31
32
33
34
# File 'lib/mirakl/mirakl_object.rb', line 29

def self.construct_from(values, opts = {})
  values = Mirakl::Util.symbolize_names(values)

  # work around protected #initialize_from for now
  new().send(:initialize_from, values, opts)
end

Instance Method Details

#dataObject



23
24
25
# File 'lib/mirakl/mirakl_object.rb', line 23

def data
  @values
end