Method: OceanDynamo::Attributes#initialize
- Defined in:
- lib/ocean-dynamo/attributes.rb
#initialize(attrs = {}) {|_self| ... } ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ocean-dynamo/attributes.rb', line 60 def initialize(attrs={}) @attributes = Hash.new fields.each do |name, md| write_attribute(name, evaluate_default(md[:default], md[:type])) end raise UnknownPrimaryKey unless table_hash_key set_belongs_to_association(attrs) # Barf on unknown attributes here? attrs && attrs.delete_if { |k, v| !fields.has_key?(k) } super(attrs) yield self if block_given? end |