class Mixture::AttributeList
A list of attributes. This is used instead of a hash in order to add in the {#options} and {#callbacks}.
Attributes
Returns a set of callbacks. This is used for coercion, but may be used for other things.
@return [Hash{Symbol => Array<Proc>}]
Returns a set of options used for the attributes. This isn't used at the moment.
@return [Hash{Symbol => Object}]
The parent of this attribute list. This is “merged” into this attribute list. This shouldn't be set since it is automatically assumed; however, sometimes it can be assumed wrong.
@return [AttributeList, nil]
Public Class Methods
Initializes the attribute list.
@param parent [AttributeList] The parent {AttributeList}. This is used
primarily for inheritance.
# File lib/mixture/attribute_list.rb, line 71 def initialize(parent = nil) @list = {} @options = {} @parent = parent @callbacks = Hash.new { |h, k| h[k] = Set.new } end
Public Instance Methods
Creates a new attribute with the given name and options.
@param name [Symbol] The name of the attribute. @param options [Hash] The options for the attribute. @return [Attribute]
# File lib/mixture/attribute_list.rb, line 83 def create(name, options = {}) @list[name] = Attribute.new(name, self, options) end
Protected Instance Methods
# File lib/mixture/attribute_list.rb, line 89 def with_parent @parent ? @list.merge(@parent.with_parent) : @list end