class Fried::Schema::Definition
Holds defined attributes for a given {Class}
Attributes
attributes[R]
Public Class Methods
new()
click to toggle source
# File lib/fried/schema/definition.rb, line 12 def initialize @attributes = {} end
Public Instance Methods
add_attribute(definition)
click to toggle source
@param attribute_definition [Attribute::Definition] @return [Attribute::Definition]
# File lib/fried/schema/definition.rb, line 18 def add_attribute(definition) name = definition.name attributes[name] = definition end
each_attribute(&block)
click to toggle source
List all attributes. If no block is passed, returns an enumerator, otherwise it returns the last value returned by the block @return [Enumerator, Object]
# File lib/fried/schema/definition.rb, line 26 def each_attribute(&block) return attributes_enumerator if block.nil? attributes_enumerator.each(&block) end
Private Instance Methods
attributes_enumerator()
click to toggle source
# File lib/fried/schema/definition.rb, line 34 def attributes_enumerator Enumerator.new(attributes.size) do |yielder| attributes.each { |_, definition| yielder << definition } end end