Class: Smplkit::Flags::NumberFlag

Inherits:
Flag
  • Object
show all
Defined in:
lib/smplkit/flags/models.rb

Instance Attribute Summary

Attributes inherited from Flag

#created_at, #default, #description, #id, #name, #type, #updated_at

Instance Method Summary collapse

Methods inherited from Flag

#_apply, #add_rule, #add_value, #clear_default, #clear_rules, #clear_values, #delete, #disable_rules, #enable_rules, #environments, #initialize, #remove_value, #save, #set_default, #values

Constructor Details

This class inherits a constructor from Smplkit::Flags::Flag

Instance Method Details

#get(context: nil) ⇒ Numeric

Evaluate this flag and return its current numeric value.

Parameters:

  • context (Array<Smplkit::Context>, nil) (defaults to: nil)

    optional entities to evaluate targeting rules against; when omitted the ambient request context (if any) is used.

Returns:

  • (Numeric)

    the evaluated numeric value, or this flag’s default when no environment override or rule applies (or the evaluated value is not a Numeric).



336
337
338
339
# File 'lib/smplkit/flags/models.rb', line 336

def get(context: nil)
  value = @client._evaluate_handle(@id, @default, context)
  value.is_a?(Numeric) ? value : @default
end