Class: FluidFeatures::App

Inherits:
Object
  • Object
show all
Defined in:
lib/fluidfeatures/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, app_id, secret, logger) ⇒ App

Returns a new instance of App.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fluidfeatures/app.rb', line 12

def initialize(client, app_id, secret, logger)

  raise "client invalid : #{client}" unless client.is_a? FluidFeatures::Client
  raise "app_id invalid : #{app_id}" unless app_id.is_a? String
  raise "secret invalid : #{secret}" unless secret.is_a? String

  @client = client
  @app_id = app_id
  @secret = secret
  @logger = logger
  @state = ::FluidFeatures::AppState.new(self)
  @reporter = ::FluidFeatures::AppReporter.new(self)

end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



10
11
12
# File 'lib/fluidfeatures/app.rb', line 10

def app_id
  @app_id
end

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/fluidfeatures/app.rb', line 10

def client
  @client
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/fluidfeatures/app.rb', line 10

def logger
  @logger
end

#reporterObject

Returns the value of attribute reporter.



10
11
12
# File 'lib/fluidfeatures/app.rb', line 10

def reporter
  @reporter
end

#secretObject

Returns the value of attribute secret.



10
11
12
# File 'lib/fluidfeatures/app.rb', line 10

def secret
  @secret
end

#stateObject

Returns the value of attribute state.



10
11
12
# File 'lib/fluidfeatures/app.rb', line 10

def state
  @state
end

Instance Method Details

#feature_version(feature_name, version_name) ⇒ Object



56
57
58
# File 'lib/fluidfeatures/app.rb', line 56

def feature_version(feature_name, version_name)
  ::FluidFeatures::AppFeatureVersion.new(self, feature_name, version_name)
end

#featuresObject

Returns all the features that FluidFeatures knows about for your application. The enabled percentage (how much of your user-base) sees each feature is also provided.



44
45
46
# File 'lib/fluidfeatures/app.rb', line 44

def features
  get("/features")
end

#get(path, params = nil, cache = false) ⇒ Object



27
28
29
# File 'lib/fluidfeatures/app.rb', line 27

def get(path, params=nil, cache=false)
  client.get("/app/#{app_id}#{path}", secret, params, cache)
end

#post(path, payload) ⇒ Object



35
36
37
# File 'lib/fluidfeatures/app.rb', line 35

def post(path, payload)
  client.post("/app/#{app_id}#{path}", secret, payload)
end

#put(path, payload) ⇒ Object



31
32
33
# File 'lib/fluidfeatures/app.rb', line 31

def put(path, payload)
  client.put("/app/#{app_id}#{path}", secret, payload)
end

#user(user_id, display_name, is_anonymous, unique_attrs, cohort_attrs) ⇒ Object



48
49
50
# File 'lib/fluidfeatures/app.rb', line 48

def user(user_id, display_name, is_anonymous, unique_attrs, cohort_attrs)
  ::FluidFeatures::AppUser.new(self, user_id, display_name, is_anonymous, unique_attrs, cohort_attrs)
end

#user_transaction(user_id, url, display_name, is_anonymous, unique_attrs, cohort_attrs) ⇒ Object



52
53
54
# File 'lib/fluidfeatures/app.rb', line 52

def user_transaction(user_id, url, display_name, is_anonymous, unique_attrs, cohort_attrs)
  user(user_id, display_name, is_anonymous, unique_attrs, cohort_attrs).transaction(url)
end