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.



49
50
51
52
53
54
55
# File 'lib/query-interface-server/transformations.rb', line 49

def initialize
  self.excludes = {}
  self.filters = {}
  self.withs = {}
  self.orders = {}
  self.updates = {}
end

Instance Attribute Details

#excludesObject

Returns the value of attribute excludes.



47
48
49
# File 'lib/query-interface-server/transformations.rb', line 47

def excludes
  @excludes
end

#filtersObject

Returns the value of attribute filters.



47
48
49
# File 'lib/query-interface-server/transformations.rb', line 47

def filters
  @filters
end

#ordersObject

Returns the value of attribute orders.



47
48
49
# File 'lib/query-interface-server/transformations.rb', line 47

def orders
  @orders
end

#updatesObject

Returns the value of attribute updates.



47
48
49
# File 'lib/query-interface-server/transformations.rb', line 47

def updates
  @updates
end

#withsObject

Returns the value of attribute withs.



47
48
49
# File 'lib/query-interface-server/transformations.rb', line 47

def withs
  @withs
end

Instance Method Details

#auto_exclude(*names) ⇒ Object



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

def auto_exclude(*names)
  names.each do |name|
    self.excludes[name] = Proc.new do |param|
      exclude(Sequel.qualify(model.table_name, name) => param)
    end
  end
end

#auto_filter(*names) ⇒ Object



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

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

#auto_update(*names) ⇒ Object



73
74
75
76
77
# File 'lib/query-interface-server/transformations.rb', line 73

def auto_update(*names)
  names.each do |name|
    self.updates[name] = Proc.new {|param| param}
  end
end

#exclude(name, &block) ⇒ Object



79
80
81
# File 'lib/query-interface-server/transformations.rb', line 79

def exclude(name, &block)
  self.excludes[name] = block
end

#filter(name, &block) ⇒ Object



83
84
85
# File 'lib/query-interface-server/transformations.rb', line 83

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

#order(name, &block) ⇒ Object



95
96
97
# File 'lib/query-interface-server/transformations.rb', line 95

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

#update(name, &block) ⇒ Object



87
88
89
# File 'lib/query-interface-server/transformations.rb', line 87

def update(name, &block)
  self.updates[name] = block
end

#with(name, &block) ⇒ Object



91
92
93
# File 'lib/query-interface-server/transformations.rb', line 91

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