Class: Magellanalytics::Configuration
- Inherits:
-
Object
- Object
- Magellanalytics::Configuration
- Defined in:
- lib/magellanalytics/configuration.rb
Instance Attribute Summary collapse
- #base_integrations ⇒ Object
- #base_props ⇒ Object
-
#segment_write_key ⇒ Object
Returns the value of attribute segment_write_key.
-
#track_user_check ⇒ Object
readonly
Returns the value of attribute track_user_check.
-
#user_traits ⇒ Object
readonly
Returns the value of attribute user_traits.
Instance Method Summary collapse
- #event_description(name) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #register_event(event, description = nil) ⇒ Object
- #register_user_traits(&block) ⇒ Object
- #registered_events ⇒ Object
- #track_user_check? ⇒ Boolean
- #track_user_if(&block) ⇒ Object
- #user_traits? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 |
# File 'lib/magellanalytics/configuration.rb', line 9 def initialize @base_integrations = {} @base_props = {} @events = {} end |
Instance Attribute Details
#base_integrations ⇒ Object
45 46 47 48 49 |
# File 'lib/magellanalytics/configuration.rb', line 45 def base_integrations return @base_integrations.call if @base_integrations.respond_to?(:call) @base_integrations end |
#base_props ⇒ Object
51 52 53 54 55 |
# File 'lib/magellanalytics/configuration.rb', line 51 def base_props return @base_props.call if @base_props.respond_to?(:call) @base_props end |
#segment_write_key ⇒ Object
Returns the value of attribute segment_write_key.
5 6 7 |
# File 'lib/magellanalytics/configuration.rb', line 5 def segment_write_key @segment_write_key end |
#track_user_check ⇒ Object (readonly)
Returns the value of attribute track_user_check.
6 7 8 |
# File 'lib/magellanalytics/configuration.rb', line 6 def track_user_check @track_user_check end |
#user_traits ⇒ Object (readonly)
Returns the value of attribute user_traits.
6 7 8 |
# File 'lib/magellanalytics/configuration.rb', line 6 def user_traits @user_traits end |
Instance Method Details
#event_description(name) ⇒ Object
23 24 25 26 27 |
# File 'lib/magellanalytics/configuration.rb', line 23 def event_description(name) raise Magellanalytics::UnregisteredEvent, "Unknown event: #{name}" unless registered_events.include?(name.to_sym) @events[name.to_sym]&.description end |
#register_event(event, description = nil) ⇒ Object
29 30 31 |
# File 'lib/magellanalytics/configuration.rb', line 29 def register_event(event, description = nil) @events[event.to_sym] = Magellanalytics::Event.new(event, description) end |
#register_user_traits(&block) ⇒ Object
41 42 43 |
# File 'lib/magellanalytics/configuration.rb', line 41 def register_user_traits(&block) @user_traits = block end |
#registered_events ⇒ Object
33 34 35 |
# File 'lib/magellanalytics/configuration.rb', line 33 def registered_events @events.keys end |
#track_user_check? ⇒ Boolean
19 20 21 |
# File 'lib/magellanalytics/configuration.rb', line 19 def track_user_check? instance_variable_defined?(:@track_user_check) end |
#track_user_if(&block) ⇒ Object
15 16 17 |
# File 'lib/magellanalytics/configuration.rb', line 15 def track_user_if(&block) @track_user_check = block end |
#user_traits? ⇒ Boolean
37 38 39 |
# File 'lib/magellanalytics/configuration.rb', line 37 def user_traits? instance_variable_defined?(:@user_traits) end |