Class: Kanji::Type::AttributeDefiner

Inherits:
Object
  • Object
show all
Extended by:
InstanceDefine
Defined in:
lib/kanji/type/attribute_definer.rb

Instance Method Summary collapse

Methods included from InstanceDefine

instance_define

Constructor Details

#initialize(name, type = nil, description = nil, **kwargs, &block) ⇒ AttributeDefiner

Returns a new instance of AttributeDefiner.

Raises:



12
13
14
15
16
17
18
19
20
# File 'lib/kanji/type/attribute_definer.rb', line 12

def initialize(name, type = nil, description = nil, **kwargs, &block)
  @_name = name
  @_type = type
  @_description = description
  @_options = kwargs
  self.instance_eval &block if block_given?

  raise AttributeError unless @_type
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
30
# File 'lib/kanji/type/attribute_definer.rb', line 22

def call
  Attribute.new({
    name: @_name,
    type: @_type,
    description: @_description,
    options: @_options,
    resolve: @_resolve
  })
end