Class: Swrve::Api::Resources

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/swrve/api/resources.rb

Instance Method Summary collapse

Constructor Details

#initializeResources

Returns a new instance of Resources.



13
14
15
# File 'lib/swrve/api/resources.rb', line 13

def initialize
  @resources_endpoint = Middleware::Http.new(Swrve.config.ab_test_url + "/api/#{Swrve.config.api_version}")
end

Instance Method Details

#resource(uuid, test_name, timestamp = nil) ⇒ Object



17
18
19
# File 'lib/swrve/api/resources.rb', line 17

def resource(uuid, test_name, timestamp = nil)
  convert_to_bools(resources(uuid, timestamp).detect{ |exists| exists['uid'] == test_name } || {})
end

#resources(uuid, timestamp = nil) ⇒ Object



21
22
23
24
# File 'lib/swrve/api/resources.rb', line 21

def resources(uuid, timestamp = nil)
  return local_resources if Swrve.config.load_local_resources
  remote_resources(uuid, true, timestamp)
end

#resources_diff(uuid, timestamp = nil) ⇒ Object



26
27
28
29
# File 'lib/swrve/api/resources.rb', line 26

def resources_diff(uuid, timestamp = nil)
  return local_resources if Swrve.config.load_local_resources
  remote_resources(uuid, false, timestamp)
end