module Entasis::Model
Public Class Methods
new(hash={})
click to toggle source
Takes a hash and assigns keys and values to it’s attributes members
# File lib/entasis/model.rb, line 37 def initialize(hash={}) self.attributes = hash end
Public Instance Methods
attributes()
click to toggle source
Returns all attributes serialized as hash
# File lib/entasis/model.rb, line 63 def attributes attribute_names.inject({}) { |h, name| h[name] = send(name); h } end
attributes=(hash)
click to toggle source
Takes a hash of attribute names and values and set each attribute.
If passwed an unkown attribute it will raise class::UnknownAttributeError
# File lib/entasis/model.rb, line 47 def attributes=(hash) hash.each do |name, value| if attribute_names.include?(name.to_s) || self.respond_to?("#{name}=") self.send("#{name}=", value) else if attributes_config[:strict] == true raise self.class::UnknownAttributeError, "unknown attribute: #{name}" end end end end