Class: Devlin::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/devlin/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



3
4
5
# File 'lib/devlin/base.rb', line 3

def initialize(params)
  @params = params
end

Class Method Details

.[](name) ⇒ Object



12
13
14
# File 'lib/devlin/base.rb', line 12

def self.[](name)
  @scopes[name.to_sym]
end

.scopesObject

returns the keys of the defined scopes



8
9
10
# File 'lib/devlin/base.rb', line 8

def self.scopes
  @scopes.keys
end

Instance Method Details

#query(q) ⇒ Object



22
23
24
# File 'lib/devlin/base.rb', line 22

def query(q)
  Query.new(self, q)
end

#scope(name) ⇒ Object



16
17
18
19
20
# File 'lib/devlin/base.rb', line 16

def scope(name)
  @scope ||= {}
  @scope[name.to_sym] ||= Scope.new(name, @params, &(self.class[name.to_sym]))
  @scope[name.to_sym]
end