Class: QueryInterface::Server::Transformations::TransformationScope

Inherits:
Object
  • Object
show all
Defined in:
lib/query-interface-server/transformations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTransformationScope

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

#filtersObject

Returns the value of attribute filters.



43
44
45
# File 'lib/query-interface-server/transformations.rb', line 43

def filters
  @filters
end

#ordersObject

Returns the value of attribute orders.



43
44
45
# File 'lib/query-interface-server/transformations.rb', line 43

def orders
  @orders
end

#withsObject

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