Class: BBAttributeFilters::Attribute
- Inherits:
-
Object
- Object
- BBAttributeFilters::Attribute
- Defined in:
- lib/bbattribute_filters/attribute.rb
Overview
The attribute class. Wraps up a single instances of an attribute with the handler and condition
Instance Method Summary collapse
- #condition_type ⇒ Object
- #evaluate(serializer) ⇒ Object
- #exclude?(serializer) ⇒ Boolean
- #include?(serializer) ⇒ Boolean
-
#initialize(name, options = {}, &block) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(name, options = {}, &block) ⇒ Attribute
Returns a new instance of Attribute.
11 12 13 14 15 16 17 |
# File 'lib/bbattribute_filters/attribute.rb', line 11 def initialize(name, = {}, &block) raise ArgumentError, 'BBAttributeFilters::Attribute - Name should be a symbol' unless name.is_a?(::Symbol) @name = name @handler = build_handler(name, &block) @condition = build_condition() end |
Instance Method Details
#condition_type ⇒ Object
31 32 33 |
# File 'lib/bbattribute_filters/attribute.rb', line 31 def condition_type @condition.type end |
#evaluate(serializer) ⇒ Object
27 28 29 |
# File 'lib/bbattribute_filters/attribute.rb', line 27 def evaluate(serializer) @handler.evaluate(serializer) end |
#exclude?(serializer) ⇒ Boolean
23 24 25 |
# File 'lib/bbattribute_filters/attribute.rb', line 23 def exclude?(serializer) @condition.exclude?(serializer) end |
#include?(serializer) ⇒ Boolean
19 20 21 |
# File 'lib/bbattribute_filters/attribute.rb', line 19 def include?(serializer) @condition.include?(serializer) end |