Class: Unleash::Bootstrap::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/unleash/bootstrap/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Handler

Returns a new instance of Handler.



9
10
11
# File 'lib/unleash/bootstrap/handler.rb', line 9

def initialize(configuration)
  self.configuration = configuration
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



7
8
9
# File 'lib/unleash/bootstrap/handler.rb', line 7

def configuration
  @configuration
end

Instance Method Details

#retrieve_togglesString

Returns JSON string representing data returned from an Unleash server.

Returns:

  • (String)

    JSON string representing data returned from an Unleash server



14
15
16
17
18
19
# File 'lib/unleash/bootstrap/handler.rb', line 14

def retrieve_toggles
  return configuration.data unless self.configuration.data.nil?
  return configuration.block.call if self.configuration.block.is_a?(Proc)
  return Provider::FromFile.read(configuration.file_path) unless self.configuration.file_path.nil?
  return Provider::FromUrl.read(configuration.url, configuration.url_headers) unless self.configuration.url.nil?
end