Class: GramV2Client::Base

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/gram_v2_client/base.rb

Direct Known Subclasses

Account, Group, Role

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(*args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gram_v2_client/base.rb', line 11

def find(*args,&block)
  begin
    super(*args,&block)
  rescue ActiveResource::ResourceNotFound => e
    raise GramV2Client::ResourceNotFound.new(
        resource: self.name,
        query: args.first,
        source_exception: e

    )
  end
end

.passwordObject



43
44
45
46
47
48
49
50
# File 'lib/gram_v2_client/base.rb', line 43

def password()
  if GramV2Client.configuration.password
    if super.to_s != GramV2Client.configuration.password
      reload_config
    end
  end
  super
end

.proxyObject



52
53
54
55
56
57
58
59
# File 'lib/gram_v2_client/base.rb', line 52

def proxy()
  if GramV2Client.configuration.proxy
    if super.to_s != URI.parse(GramV2Client.configuration.proxy).to_s
      reload_config
    end
  end
  super
end

.reload_configObject



62
63
64
65
66
67
# File 'lib/gram_v2_client/base.rb', line 62

def reload_config
  self.site= GramV2Client.configuration.site
  self.user= GramV2Client.configuration.user
  self.password=GramV2Client.configuration.password
  self.proxy=GramV2Client.configuration.proxy
end

.siteObject

This is set to enable Configuration change at runtime.



25
26
27
28
29
30
31
32
# File 'lib/gram_v2_client/base.rb', line 25

def site
  if GramV2Client.configuration.site
    if super.to_s != URI.parse(GramV2Client.configuration.site).to_s
      reload_config
    end
  end
  super
end

.userObject



34
35
36
37
38
39
40
41
# File 'lib/gram_v2_client/base.rb', line 34

def user()
  if GramV2Client.configuration.user
    if super.to_s != GramV2Client.configuration.user
      reload_config
    end
  end
  super
end

Instance Method Details

#to_paramObject



5
6
7
# File 'lib/gram_v2_client/base.rb', line 5

def to_param
  uuid
end