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) ⇒ Boolean
Checks whether two objects are equal.
-
#initialize(name, condition, options = {}) ⇒ Field
constructor
Initializes new instance of Field.
Constructor Details
#initialize(name, condition, options = {}) ⇒ Field
Initializes new instance of Field.
12 13 14 15 16 17 18 |
# File 'lib/filter_factory/field.rb', line 12 def initialize(name, condition, = {}) fail 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) ⇒ Boolean
Checks whether two objects are equal. Returns true if obj is of the same class and has name, condition and alias attributes equal to current object.
26 27 28 29 30 31 |
# File 'lib/filter_factory/field.rb', line 26 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 |