lib/hanami/entity.rb in hanami-model-1.0.4 vs lib/hanami/entity.rb in hanami-model-1.1.0.beta1
- old
+ new
@@ -31,11 +31,11 @@
# def initialize(attributes = {})
# @id, @name, @age = attributes.values_at(:id, :name, :age)
# end
# end
#
- # **Hanami::Model** ships `Hanami::Entity` for developers' convenience.
+ # **Hanami::Model** ships `Hanami::Entity` for developers's convenience.
#
# **Hanami::Model** depends on a narrow and well-defined interface for an
# Entity - `#id`, `#id=`, `#initialize(attributes={})`.If your object
# implements that interface then that object can be used as an Entity in the
# **Hanami::Model** framework.
@@ -73,16 +73,17 @@
# If you're working with an entity that isn't "backed" by a SQL table or
# with a schema-less database, you may want to manually setup a set of
# attributes via this DSL. If you don't do any setup, the entity accepts all
# the given attributes.
#
+ # @param type [Symbol] the type of schema to build
# @param blk [Proc] the block that defines the attributes
#
# @since 0.7.0
#
# @see Hanami::Entity
- def attributes(&blk)
- self.schema = Schema.new(&blk)
+ def attributes(type = nil, &blk)
+ self.schema = Schema.new(type, &blk)
@attributes = true
end
# Assign a schema
#