Class: Databasedotcom::Isolated::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/databasedotcom/isolated/scope.rb

Overview

Shared functionatily of an isolated scope

Constant Summary collapse

CLIENT_OPTIONS =
[:client_id,:client_secret]
AUTHENTICATION_OPTIONS =
[:username, :password, :token]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.bindingObject

Returns the value of attribute binding.



16
17
18
# File 'lib/databasedotcom/isolated/scope.rb', line 16

def binding
  @binding
end

.clientObject

Returns the value of attribute client.



16
17
18
# File 'lib/databasedotcom/isolated/scope.rb', line 16

def client
  @client
end

.optionsObject

Returns the value of attribute options.



16
17
18
# File 'lib/databasedotcom/isolated/scope.rb', line 16

def options
  @options
end

Class Method Details

.const_missing(sym) ⇒ Object

Search for missing constants on the current list of sobjects if available



48
49
50
51
52
53
54
# File 'lib/databasedotcom/isolated/scope.rb', line 48

def const_missing(sym)
  if self.list_sobjects.include?(sym.to_s)
    self.client.materialize(sym.to_s)
  else
    super
  end
end

.list_sobjectsObject



56
57
58
# File 'lib/databasedotcom/isolated/scope.rb', line 56

def list_sobjects
  @list_sobjects ||= self.client.list_sobjects
end

.method_missing(sym, *args) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/databasedotcom/isolated/scope.rb', line 38

def method_missing(sym,*args)
  if args.empty?
    eval(sym.to_s,binding)
  else
    context = eval("self",binding)
    context.send(sym,*args)
  end
end

.new(options = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/databasedotcom/isolated/scope.rb', line 8

def Scope.new(options = {})
  Class.new(self).tap do |scope|
    scope.options = options
    scope.client = options[:client]
  end
end

.perform(&block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/databasedotcom/isolated/scope.rb', line 27

def perform(&block)
  # self.new.instance_eval(&block)
  self.binding = block.binding
  (self.class_eval(block.to_source)).call
  self.binding = nil

  # self.class_eval( &eval(block.to_source) )

  self
end