Class: Plutonium::Query::Filter
- Defined in:
- lib/plutonium/query/filter.rb
Direct Known Subclasses
Plutonium::Query::Filters::Association, Plutonium::Query::Filters::Boolean, Plutonium::Query::Filters::Date, Plutonium::Query::Filters::DateRange, Plutonium::Query::Filters::Select, Plutonium::Query::Filters::Text
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
-
.lookup(type) ⇒ Class
Lookup a filter class by type symbol or return the class if already a Filter.
Instance Method Summary collapse
-
#initialize(key:) ⇒ Filter
constructor
A new instance of Filter.
Methods inherited from Base
Methods included from Definition::Presentable
Constructor Details
#initialize(key:) ⇒ Filter
Returns a new instance of Filter.
20 21 22 23 |
# File 'lib/plutonium/query/filter.rb', line 20 def initialize(key:) super() @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/plutonium/query/filter.rb', line 4 def key @key end |
Class Method Details
.lookup(type) ⇒ Class
Lookup a filter class by type symbol or return the class if already a Filter
10 11 12 13 14 15 16 17 |
# File 'lib/plutonium/query/filter.rb', line 10 def lookup(type) return type if type.is_a?(Class) && type < Filter class_name = "Plutonium::Query::Filters::#{type.to_s.classify}" class_name.constantize rescue NameError raise ArgumentError, "Unknown filter type: #{type}. Expected #{class_name} to exist." end |