joshuabowers / opium

An Object Parse.com Mapping technology for defining models.
MIT License
1 stars 0 forks source link

Opium::Model::Attributable#attributes=: should be able to set non-field attributes without them hitting the database #10

Closed joshuabowers closed 9 years ago

joshuabowers commented 9 years ago

Ideally, if the model has a field that matches the passed hash key, or responds to a setter matching that key, then it should delegate via send to the appropriate setter method. Otherwise, it should default to storing within the attributes hash.

Use case:

class User
  include Opium::Model
  field :password, type: String
  attr_accessor :password_confirmation
end

u = User.new( password: "redacted", password_confirmation: "redacted" )

u.attributes.has_key?( :password_confirmation ) # should be false; currently true.