Class: Fried::Schema::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/fried/schema/definition.rb

Overview

Holds defined attributes for a given Class

Instance Method Summary collapse

Constructor Details

#initializeDefinition

Returns a new instance of Definition.



12
13
14
# File 'lib/fried/schema/definition.rb', line 12

def initialize
  @attributes = {}
end

Instance Method Details

#add_attribute(definition) ⇒ Attribute::Definition

Parameters:

Returns:



18
19
20
21
# File 'lib/fried/schema/definition.rb', line 18

def add_attribute(definition)
  name = definition.name
  attributes[name] = definition
end

#each_attribute(&block) ⇒ Enumerator, Object

List all attributes. If no block is passed, returns an enumerator, otherwise it returns the last value returned by the block

Returns:

  • (Enumerator, Object)


26
27
28
29
30
# File 'lib/fried/schema/definition.rb', line 26

def each_attribute(&block)
  return attributes_enumerator if block.nil?

  attributes_enumerator.each(&block)
end