Class: MonsterQueries::Builder
- Inherits:
-
Object
- Object
- MonsterQueries::Builder
show all
- Defined in:
- lib/monster_queries/builder.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name) ⇒ Builder
Returns a new instance of Builder.
11
12
13
14
|
# File 'lib/monster_queries/builder.rb', line 11
def initialize name
@paginate = false
@scope = [name]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, args = nil) ⇒ Object
16
17
18
19
|
# File 'lib/monster_queries/builder.rb', line 16
def method_missing name, args=nil
@scope << name
file_exists? ? file_contents(args) : self
end
|
Instance Attribute Details
#paginate ⇒ Object
32
33
34
35
|
# File 'lib/monster_queries/builder.rb', line 32
def paginate
@paginate = true
self
end
|
#scope=(value) ⇒ Object
9
10
11
|
# File 'lib/monster_queries/builder.rb', line 9
def scope=(value)
@scope = value
end
|
Class Method Details
.with_scope(args) ⇒ Object
3
4
5
6
7
|
# File 'lib/monster_queries/builder.rb', line 3
def self.with_scope args
q = self.new nil
q.scope = args
q
end
|
Instance Method Details
#to_s(args = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/monster_queries/builder.rb', line 21
def to_s args={}
if file_exists?
::Rails.logger.tagged('MONSTER QUERY') do
::Rails.logger.info {"Rendered #{@scope.join('.')}"}
end
file_contents args
else
raise "Query doesn't exist: #{@scope.join('.')}"
end
end
|