module AWS::Record::AbstractBase::ClassMethods
def add_attribute attribute
- Private: -
def add_attribute attribute attr_name = attribute.name attributes[attr_name] = attribute # setter define_method("#{attr_name}=") do |value| self[attr_name] = value end # getter define_method(attr_name) do self[attr_name] end # before type-cast getter define_method("#{attr_name}_before_type_cast") do @_data[attr_name] end ## dirty tracking methods define_method("#{attr_name}_changed?") do attribute_changed?(attr_name) end define_method("#{attr_name}_change") do attribute_change(attr_name) end define_method("#{attr_name}_was") do attribute_was(attr_name) end define_method("#{attr_name}_will_change!") do attribute_will_change!(attr_name) end define_method("reset_#{attr_name}!") do reset_attribute!(attr_name) end attribute end
def attribute_for attribute_name, &block
- Private: -
def attribute_for attribute_name, &block unless attribute = attributes[attribute_name.to_s] raise UndefinedAttributeError.new(attribute_name.to_s) end block_given? ? yield(attribute) : attribute end
def attributes
-
(Hash
- Returns a hash of all of the)
def attributes @attributes ||= {} end
def new_scope
- Private: -
def new_scope self::Scope.new(self) end
def optimistic_locking attribute_name = :version_id
def optimistic_locking attribute_name = :version_id attribute = integer_attr(attribute_name) @optimistic_locking_attr = attribute end
def optimistic_locking?
-
(Boolean)
- Returns true if this class is configured to
def optimistic_locking? !!@optimistic_locking_attr end
def optimistic_locking_attr
def optimistic_locking_attr @optimistic_locking_attr end
def scope name, scope = nil, &block
-
scope
(Scope
) -- -
name
(Symbol
) -- The name of the scope. Scope names should be
def scope name, scope = nil, &block method_definition = scope ? lambda { scope } : block extend(Module.new { define_method(name, &method_definition) }) end
def set_shard_name name
-
name
(String
) --
def set_shard_name name @_shard_name = name end
def shard_name name = nil
-
(String)
- Returns the full prefixed domain name for this class.
Parameters:
-
name
(String
) -- Defaults to the name of this class.
def shard_name name = nil case name when nil @_shard_name || self.name when AWS::DynamoDB::Table name.name.gsub(/^#{Record::table_prefix}/, '') when AWS::SimpleDB::Domain name.name.gsub(/^#{Record::domain_prefix}/, '') else name end end