Module: BBAttributeFilters::ClassMethods
- Defined in:
- lib/bbattribute_filters.rb
Overview
The class methods on BBAttributeFilters
Instance Method Summary collapse
-
#_add_filterable_attribute(key, attr) ⇒ Object
Adds a single serialized attribute.
-
#_get_fiterable_attributes ⇒ Object
Gets the serialized attributes variable.
-
#_set_fiterable_attributes(attrs) ⇒ Object
Sets the serialized attributes variable.
-
#attribute(name, options = {}, &block) ⇒ Object
Assigns a single attribute.
-
#attributes(*attrs) ⇒ Object
Assigns a large set of attributes without options.
- #inherited(base) ⇒ Object
Instance Method Details
#_add_filterable_attribute(key, attr) ⇒ Object
Adds a single serialized attribute. This is an internal method used by the attribute method
87 88 89 |
# File 'lib/bbattribute_filters.rb', line 87 def _add_filterable_attribute(key, attr) @_filterable_attributes[key] = attr end |
#_get_fiterable_attributes ⇒ Object
Gets the serialized attributes variable
81 82 83 |
# File 'lib/bbattribute_filters.rb', line 81 def _get_fiterable_attributes @_filterable_attributes end |
#_set_fiterable_attributes(attrs) ⇒ Object
Sets the serialized attributes variable
76 77 78 |
# File 'lib/bbattribute_filters.rb', line 76 def _set_fiterable_attributes(attrs) @_filterable_attributes = attrs end |
#attribute(name, options = {}, &block) ⇒ Object
Assigns a single attribute
70 71 72 73 |
# File 'lib/bbattribute_filters.rb', line 70 def attribute(name, = {}, &block) _add_filterable_attribute(.fetch(:key, name), BBAttributeFilters::Attribute.new(name, , &block)) end |
#attributes(*attrs) ⇒ Object
Assigns a large set of attributes without options
63 64 65 66 67 |
# File 'lib/bbattribute_filters.rb', line 63 def attributes(*attrs) attrs.each do |attr| attribute(attr) end end |
#inherited(base) ⇒ Object
57 58 59 60 |
# File 'lib/bbattribute_filters.rb', line 57 def inherited(base) super base._set_fiterable_attributes(@_filterable_attributes ? @_filterable_attributes.dup : {}) end |