module Mince::Model::Fields

Attributes

id[RW]

Public Class Methods

new(hash={}) click to toggle source

Sets values (for fields defined by calling .field or .fields) in the hash to the object includes assignable and non-assignable fields

# File lib/mince/model/fields.rb, line 70
def initialize(hash={})
  @id = hash[:id]
  readonly_fields.each do |field_name|
    self.instance_variable_set("@#{field_name}", hash[field_name]) if hash[field_name]
  end
  self.attributes = hash
end

Public Instance Methods

attributes=(hash={}) click to toggle source

Sets values (for assignable fields only, defined by calling .field or .fields) in the hash to the object.

Allows the proxy to have whitelisted attributes to be assigned from http requests.

# File lib/mince/model/fields.rb, line 82
def attributes=(hash={})
  assignable_fields.each do |field|
    send("#{field}=", hash[field]) if hash[field]
  end
end