Class: QueryInterface::Server::Transformations::TransformationScope
- Inherits:
-
Object
- Object
- QueryInterface::Server::Transformations::TransformationScope
- Defined in:
- lib/query-interface-server/transformations.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#orders ⇒ Object
Returns the value of attribute orders.
-
#withs ⇒ Object
Returns the value of attribute withs.
Instance Method Summary collapse
- #auto_filter(*names) ⇒ Object
- #filter(name, &block) ⇒ Object
-
#initialize ⇒ TransformationScope
constructor
A new instance of TransformationScope.
- #order(name, &block) ⇒ Object
- #with(name, &block) ⇒ Object
Constructor Details
#initialize ⇒ TransformationScope
Returns a new instance of TransformationScope.
45 46 47 48 49 |
# File 'lib/query-interface-server/transformations.rb', line 45 def initialize self.filters = {} self.withs = {} self.orders = {} end |
Instance Attribute Details
#filters ⇒ Object
Returns the value of attribute filters.
43 44 45 |
# File 'lib/query-interface-server/transformations.rb', line 43 def filters @filters end |
#orders ⇒ Object
Returns the value of attribute orders.
43 44 45 |
# File 'lib/query-interface-server/transformations.rb', line 43 def orders @orders end |
#withs ⇒ Object
Returns the value of attribute withs.
43 44 45 |
# File 'lib/query-interface-server/transformations.rb', line 43 def withs @withs end |
Instance Method Details
#auto_filter(*names) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/query-interface-server/transformations.rb', line 51 def auto_filter(*names) names.each do |name| self.filters[name] = Proc.new do |param| filter(Sequel.qualify(model.table_name, name) => param) end end end |
#filter(name, &block) ⇒ Object
59 60 61 |
# File 'lib/query-interface-server/transformations.rb', line 59 def filter(name, &block) self.filters[name] = block end |
#order(name, &block) ⇒ Object
67 68 69 |
# File 'lib/query-interface-server/transformations.rb', line 67 def order(name, &block) self.orders[name] = block end |
#with(name, &block) ⇒ Object
63 64 65 |
# File 'lib/query-interface-server/transformations.rb', line 63 def with(name, &block) self.withs[name] = block end |