class Opto::Model::AttributeCollection
Attributes
group[R]
members[R]
Public Class Methods
new(attribute_definitions = [])
click to toggle source
# File lib/opto/model/attribute_collection.rb, line 13 def initialize(attribute_definitions = []) @members = {} @group = Opto::Group.new build_members(attribute_definitions) end
Public Instance Methods
[](name)
click to toggle source
# File lib/opto/model/attribute_collection.rb, line 27 def [](name) members[name] end
build_member(definition)
click to toggle source
# File lib/opto/model/attribute_collection.rb, line 31 def build_member(definition) members[definition[:name]] = Attribute.new(self, definition, group.build_option(definition)) end
build_members(definitions)
click to toggle source
# File lib/opto/model/attribute_collection.rb, line 35 def build_members(definitions) definitions.each { |definition| build_member(definition) } end
errors()
click to toggle source
# File lib/opto/model/attribute_collection.rb, line 39 def errors Hash[*group.errors.flat_map { |k,v| [k.to_sym, v] }] end
inspect()
click to toggle source
# File lib/opto/model/attribute_collection.rb, line 20 def inspect string = "#<#{self.class.name}:#{self.object_id} " string << "members: #{members.keys.inspect}" string << ">" string end