module Dinamo::Model::Attributes

Attributes

attributes[R]

Public Instance Methods

==(other) click to toggle source
# File lib/dinamo/model/attributes.rb, line 149
def ==(other)
  return false unless other.kind_of?(Dinamo::Model)
  hash_key == other.hash_key && range_key == other.range_key
end
Also aliased as: equal?
[](key) click to toggle source
# File lib/dinamo/model/attributes.rb, line 116
def [](key)
  attributes[key]
end
[]=(key, value) click to toggle source
# File lib/dinamo/model/attributes.rb, line 120
def []=(key, value)
  self.attributes = { key => value }
end
attributes=(attrs) click to toggle source
# File lib/dinamo/model/attributes.rb, line 129
def attributes=(attrs)
  attrs.each_pair do |key, val|
    name = "#{key}="
    self.class.define_attribute_method(key) unless respond_to?(name)
    send(name, val)
  end
end
equal?(other)
Alias for: ==
hash_key() click to toggle source
# File lib/dinamo/model/attributes.rb, line 137
def hash_key
  attributes[self.class.primary_keys[:hash]]
end
primary_keys() click to toggle source
# File lib/dinamo/model/attributes.rb, line 155
def primary_keys
  self.class.primary_keys.inject({}) do |keys, (_, key)|
    keys.merge(key => attributes[key])
  end
end
range_key() click to toggle source
# File lib/dinamo/model/attributes.rb, line 141
def range_key
  attributes[self.class.primary_keys[:range]]
end
silent_assign(new_attributes) click to toggle source
# File lib/dinamo/model/attributes.rb, line 145
def silent_assign(new_attributes)
  @attributes.merge!(new_attributes)
end
variable_attributes() click to toggle source
# File lib/dinamo/model/attributes.rb, line 124
def variable_attributes
  keys = primary_keys.keys
  attributes.select { |key, _| !keys.include?(key.to_sym) }
end