Class: Fried::Schema::Definition
- Inherits:
-
Object
- Object
- Fried::Schema::Definition
- Defined in:
- lib/fried/schema/definition.rb
Overview
Holds defined attributes for a given Class
Instance Method Summary collapse
- #add_attribute(definition) ⇒ Attribute::Definition
-
#each_attribute(&block) ⇒ Enumerator, Object
List all attributes.
-
#initialize ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize ⇒ Definition
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
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
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 |