Class: Symphonia::ModelFilters::Base
- Defined in:
- lib/symphonia/model_filters/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #apply(_scope) ⇒ Object
- #form_field(_c) ⇒ Object
-
#initialize(attribute, query, options = {}) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
Constructor Details
#initialize(attribute, query, options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/symphonia/model_filters/base.rb', line 9 def initialize(attribute, query, = {}) if attribute.is_a? String ActiveSupport::Deprecation.warn("name as argument is no longer supported - use Attribute") @name = attribute else @name = attribute.name @attribute = attribute end @options = @query = query @operator = 'eq' end |
Instance Attribute Details
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
4 5 6 |
# File 'lib/symphonia/model_filters/base.rb', line 4 def @caption end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/symphonia/model_filters/base.rb', line 4 def name @name end |
#operator ⇒ Object
Returns the value of attribute operator.
4 5 6 |
# File 'lib/symphonia/model_filters/base.rb', line 4 def operator @operator end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/symphonia/model_filters/base.rb', line 4 def @options end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
4 5 6 |
# File 'lib/symphonia/model_filters/base.rb', line 4 def query @query end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/symphonia/model_filters/base.rb', line 4 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/symphonia/model_filters/base.rb', line 4 def value @value end |
Instance Method Details
#active? ⇒ Boolean
35 36 37 |
# File 'lib/symphonia/model_filters/base.rb', line 35 def active? !!query.active_filters[name] end |
#apply(_scope) ⇒ Object
70 71 72 |
# File 'lib/symphonia/model_filters/base.rb', line 70 def apply(_scope) Rails.logger.debug("Apply filter #{name} '#{operator}' #{value}") end |
#form_field(_c) ⇒ Object
27 28 29 |
# File 'lib/symphonia/model_filters/base.rb', line 27 def form_field(_c) raise NotImplementError end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/symphonia/model_filters/base.rb', line 31 def inspect "#<#{self.class.name} name='#{name}' caption='#{}' options=#{@options.inspect}>" end |