Class: Beaconable::ObjectWas

Inherits:
Object
  • Object
show all
Defined in:
lib/beaconable/object_was.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ ObjectWas

Returns a new instance of ObjectWas.



7
8
9
# File 'lib/beaconable/object_was.rb', line 7

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/beaconable/object_was.rb', line 5

def object
  @object
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
# File 'lib/beaconable/object_was.rb', line 11

def call
  hashed_object = {}
  symbolized_column_names = object.class.column_names.map(&:to_sym)
  symbolized_column_names.each do |column_name|
    hashed_object[column_name] = object.send("#{column_name}_was")
  end
  OpenStruct.new(hashed_object)
end