Class: Mixture::AttributeList
- Inherits:
-
Object
- Object
- Mixture::AttributeList
- Extended by:
- Forwardable
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/mixture/attribute_list.rb
Overview
A list of attributes. This is used instead of a hash in order to add in the #options and #callbacks.
Instance Attribute Summary collapse
-
#callbacks ⇒ Hash{Symbol => Array<Proc>}
readonly
Returns a set of callbacks.
-
#options ⇒ Hash{Symbol => Object}
readonly
Returns a set of options used for the attributes.
Instance Method Summary collapse
-
#create(name, options = {}) ⇒ Attribute
Creates a new attribute with the given name and options.
-
#initialize ⇒ AttributeList
constructor
Initializes the attribute list.
Constructor Details
#initialize ⇒ AttributeList
Initializes the attribute list.
31 32 33 34 35 |
# File 'lib/mixture/attribute_list.rb', line 31 def initialize @list = {} = {} @callbacks = Hash.new { |h, k| h[k] = Set.new } end |
Instance Attribute Details
#callbacks ⇒ Hash{Symbol => Array<Proc>} (readonly)
Returns a set of callbacks. This is used for coercion, but may be used for other things.
28 29 30 |
# File 'lib/mixture/attribute_list.rb', line 28 def callbacks @callbacks end |
#options ⇒ Hash{Symbol => Object} (readonly)
Returns a set of options used for the attributes. This isn't used at the moment.
22 23 24 |
# File 'lib/mixture/attribute_list.rb', line 22 def end |
Instance Method Details
#create(name, options = {}) ⇒ Attribute
Creates a new attribute with the given name and options.
42 43 44 |
# File 'lib/mixture/attribute_list.rb', line 42 def create(name, = {}) @list[name] = Attribute.new(name, self, ) end |