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

API:

  • private

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

API:

  • private



102
103
104
# File 'lib/hanami/entity.rb', line 102

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.

See Also:

Since:

  • 0.7.0

Parameters:

  • (defaults to: nil)

    the type of schema to build

  • the block that defines the attributes

API:

  • private



84
85
86
87
# File 'lib/hanami/entity.rb', line 84

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