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
58
# File 'lib/query-interface-server/transformations.rb', line 51

def auto_filter(*names)
  names.each do |name|
    self.filters[name] = Proc.new do |param|
      field = "#{model.table_name}__#{name}".to_sym
      filter(field => param)
    end
  end
end

#filter(name, &block) ⇒ Object



60
61
62
# File 'lib/query-interface-server/transformations.rb', line 60

def filter(name, &block)
  self.filters[name] = block
end

#order(name, &block) ⇒ Object



68
69
70
# File 'lib/query-interface-server/transformations.rb', line 68

def order(name, &block)
  self.orders[name] = block
end

#with(name, &block) ⇒ Object



64
65
66
# File 'lib/query-interface-server/transformations.rb', line 64

def with(name, &block)
  self.withs[name] = block
end