Module: Hanami::Entity::ClassMethods Private

Defined in:
lib/hanami/entity.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class level interface

Since:

  • 0.7.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#schemaObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.7.0



105
106
107
# File 'lib/hanami/entity.rb', line 105

def schema
  @schema
end

Instance Method Details

#attributes(type = nil, &blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Define manual entity schema

With a SQL database this setup happens automatically and you SHOULD NOT use this DSL. You should use only when you want to customize the automatic setup.

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.

Parameters:

  • type (Symbol) (defaults to: nil)

    the type of schema to build

  • blk (Proc)

    the block that defines the attributes

See Also:

Since:

  • 0.7.0



86
87
88
89
# File 'lib/hanami/entity.rb', line 86

def attributes(type = nil, &blk)
  self.schema = Schema.new(type, &blk)
  @attributes = true
end