Class: FilterFactory::Field
- Inherits:
-
Object
- Object
- FilterFactory::Field
- Defined in:
- lib/filter_factory/field.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(name, condition, options = {}) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(name, condition, options = {}) ⇒ Field
Returns a new instance of Field.
6 7 8 9 10 11 12 |
# File 'lib/filter_factory/field.rb', line 6 def initialize(name, condition, = {}) raise ArgumentError unless FilterFactory::Filter::CONDITIONS.include?(condition) = [:alias] @name, @condition, @options = name, condition, .reject{|k,| !.include?(k)} @alias = @options[:alias] || @name end |
Instance Attribute Details
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
3 4 5 |
# File 'lib/filter_factory/field.rb', line 3 def alias @alias end |
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
3 4 5 |
# File 'lib/filter_factory/field.rb', line 3 def condition @condition end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/filter_factory/field.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/filter_factory/field.rb', line 3 def @options end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/filter_factory/field.rb', line 4 def value @value end |
Instance Method Details
#==(obj) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/filter_factory/field.rb', line 14 def ==(obj) return false unless obj.is_a?(self.class) [:name, :condition, :alias].inject(true) do |acc,attr| acc && public_send(attr) == obj.public_send(attr) end end |