Class: ActiveRecordSegment::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



16
17
18
19
20
21
22
23
# File 'lib/active_record_segment.rb', line 16

def initialize
 # Set default value if user forget to configure 
  self.ignored_attributes = DEFAULT_IGNORED_ATTRIBUTES
  self.ignored_klasses = []
  self.enabled = false
  self.env = defined?(Rails) && Rails.env.to_s
  self.logger = Logger.new(STDOUT)
end

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



14
15
16
# File 'lib/active_record_segment.rb', line 14

def enabled
  @enabled
end

#envObject

Returns the value of attribute env.



14
15
16
# File 'lib/active_record_segment.rb', line 14

def env
  @env
end

#ignored_attributesObject

Returns the value of attribute ignored_attributes.



14
15
16
# File 'lib/active_record_segment.rb', line 14

def ignored_attributes
  @ignored_attributes
end

#ignored_klassesObject

Returns the value of attribute ignored_klasses.



14
15
16
# File 'lib/active_record_segment.rb', line 14

def ignored_klasses
  @ignored_klasses
end

#loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/active_record_segment.rb', line 14

def logger
  @logger
end

#segment_write_keyObject

Returns the value of attribute segment_write_key.



14
15
16
# File 'lib/active_record_segment.rb', line 14

def segment_write_key
  @segment_write_key
end

Instance Method Details

#segment_analyticObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/active_record_segment.rb', line 25

def segment_analytic
  if segment_write_key.nil?
    raise StandardError.new("Please config segment write key before call this method") 
  end

  @segment_analytic ||= Segment::Analytics.new(
    write_key: segment_write_key,
    on_error: proc { |status, msg| print msg }
    )
end