Class: Moonrope::DSL::FilterableDSL
- Inherits:
-
Object
- Object
- Moonrope::DSL::FilterableDSL
- Defined in:
- lib/moonrope/dsl/filterable_dsl.rb
Instance Method Summary collapse
- #attribute(name, options = {}, &block) ⇒ Object
-
#initialize(action) ⇒ FilterableDSL
constructor
A new instance of FilterableDSL.
Constructor Details
#initialize(action) ⇒ FilterableDSL
Returns a new instance of FilterableDSL.
5 6 7 |
# File 'lib/moonrope/dsl/filterable_dsl.rb', line 5 def initialize(action) @action = action end |
Instance Method Details
#attribute(name, options = {}, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/moonrope/dsl/filterable_dsl.rb', line 9 def attribute(name, = {}, &block) if [:type] == Integer || [:type] == Float # Numbers [:operators] ||= [:eq, :not_eq, :gt, :gte, :lt, :lte, :in, :not_in] elsif [:type] == String # Strings [:operators] ||= [:eq, :not_eq, :starts_with, :ends_with, :in, :not_in] elsif [:type] == :timestamp # Times [:operators] ||= [:eq, :not_eq, :gt, :gte, :lt, :lte] else # Everything else [:operators] ||= [:eq, :not_eq] end @action.filters[name] = .merge(:name => name, :block => block) end |