Module: ActiveMocker::Base::PropertiesGetterAndSetter

Included in:
ActiveMocker::Base
Defined in:
lib/active_mocker/mock/base.rb

Instance Method Summary collapse

Instance Method Details

#read_attribute(attr) ⇒ Object

Returns the value of the attribute identified by attr_name after it has been typecast (for example, “2004-12-12” in a date column is cast to a date object, like Date.new(2004, 12, 12))



353
354
355
# File 'lib/active_mocker/mock/base.rb', line 353

def read_attribute(attr)
  @attributes[attr]
end

#write_attribute(attr, value) ⇒ Object

Updates the attribute identified by attr_name with the specified value. Empty strings for fixnum and float columns are turned into nil.



360
361
362
# File 'lib/active_mocker/mock/base.rb', line 360

def write_attribute(attr, value)
  @attributes[attr] = types[attr].coerce(value)
end