Class: Toggler
- Inherits:
-
Object
- Object
- Toggler
- Defined in:
- lib/tailslide/toggler.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#emit_redis_signal ⇒ Object
readonly
Returns the value of attribute emit_redis_signal.
-
#flag_id ⇒ Object
Returns the value of attribute flag_id.
-
#flag_name ⇒ Object
readonly
Returns the value of attribute flag_name.
-
#get_flags ⇒ Object
readonly
Returns the value of attribute get_flags.
-
#user_context ⇒ Object
readonly
Returns the value of attribute user_context.
Instance Method Summary collapse
- #emit_failure ⇒ Object
- #emit_success ⇒ Object
-
#initialize(flag_name: '', get_flags: nil, emit_redis_signal: nil, user_context: '') ⇒ Toggler
constructor
A new instance of Toggler.
- #is_flag_active ⇒ Object
Constructor Details
#initialize(flag_name: '', get_flags: nil, emit_redis_signal: nil, user_context: '') ⇒ Toggler
Returns a new instance of Toggler.
7 8 9 10 11 12 13 14 15 |
# File 'lib/tailslide/toggler.rb', line 7 def initialize(flag_name: '', get_flags: nil, emit_redis_signal: nil, user_context: '') @flag_name = flag_name @get_flags = get_flags @flag_id = nil @app_id = nil set_flag_id_and_app_id(flag_name) @emit_redis_signal = emit_redis_signal @user_context = user_context end |
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
5 6 7 |
# File 'lib/tailslide/toggler.rb', line 5 def app_id @app_id end |
#emit_redis_signal ⇒ Object (readonly)
Returns the value of attribute emit_redis_signal.
4 5 6 |
# File 'lib/tailslide/toggler.rb', line 4 def emit_redis_signal @emit_redis_signal end |
#flag_id ⇒ Object
Returns the value of attribute flag_id.
5 6 7 |
# File 'lib/tailslide/toggler.rb', line 5 def flag_id @flag_id end |
#flag_name ⇒ Object (readonly)
Returns the value of attribute flag_name.
4 5 6 |
# File 'lib/tailslide/toggler.rb', line 4 def flag_name @flag_name end |
#get_flags ⇒ Object (readonly)
Returns the value of attribute get_flags.
4 5 6 |
# File 'lib/tailslide/toggler.rb', line 4 def get_flags @get_flags end |
#user_context ⇒ Object (readonly)
Returns the value of attribute user_context.
4 5 6 |
# File 'lib/tailslide/toggler.rb', line 4 def user_context @user_context end |
Instance Method Details
#emit_failure ⇒ Object
29 30 31 32 33 |
# File 'lib/tailslide/toggler.rb', line 29 def emit_failure return unless flag_id emit_redis_signal.call(flag_id, app_id, 'failure') end |
#emit_success ⇒ Object
22 23 24 25 26 27 |
# File 'lib/tailslide/toggler.rb', line 22 def emit_success return unless flag_id p 'emiting success' emit_redis_signal.call(flag_id, app_id, 'success') end |
#is_flag_active ⇒ Object
17 18 19 20 |
# File 'lib/tailslide/toggler.rb', line 17 def is_flag_active flag = get_matching_flag flag['is_active'] && (is_user_white_listed(flag) || validate_user_rollout(flag)) end |