Class: SimpleAnalyticsRails::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/simple_analytics_rails/configuration.rb', line 3

def initialize
  @hostname = ""
  @mode = ""
  @ignore_pages = ""
  @collect_dnt = false
  @enabled = true
  @custom_domain = ""
  @auto_collect = true
  @sa_global = "sa_event"
  @onload_callback = ""
end

Instance Attribute Details

#auto_collect=(value) ⇒ Object (writeonly)

Sets the attribute auto_collect

Parameters:

  • value

    the value to set the attribute auto_collect to.



43
44
45
# File 'lib/simple_analytics_rails/configuration.rb', line 43

def auto_collect=(value)
  @auto_collect = value
end

#collect_dnt=(value) ⇒ Object (writeonly)

Sets the attribute collect_dnt

Parameters:

  • value

    the value to set the attribute collect_dnt to.



24
25
26
# File 'lib/simple_analytics_rails/configuration.rb', line 24

def collect_dnt=(value)
  @collect_dnt = value
end

#custom_domain=(value) ⇒ Object (writeonly)

Sets the attribute custom_domain

Parameters:

  • value

    the value to set the attribute custom_domain to.



34
35
36
# File 'lib/simple_analytics_rails/configuration.rb', line 34

def custom_domain=(value)
  @custom_domain = value
end

#enabled=(value) ⇒ Object (writeonly)

Sets the attribute enabled

Parameters:

  • value

    the value to set the attribute enabled to.



29
30
31
# File 'lib/simple_analytics_rails/configuration.rb', line 29

def enabled=(value)
  @enabled = value
end

#hostnameObject

Returns the value of attribute hostname.



16
17
18
# File 'lib/simple_analytics_rails/configuration.rb', line 16

def hostname
  @hostname
end

#ignore_pagesObject

Returns the value of attribute ignore_pages.



15
16
17
# File 'lib/simple_analytics_rails/configuration.rb', line 15

def ignore_pages
  @ignore_pages
end

#modeObject

Returns the value of attribute mode.



17
18
19
# File 'lib/simple_analytics_rails/configuration.rb', line 17

def mode
  @mode
end

#onload_callbackObject

Returns the value of attribute onload_callback.



48
49
50
# File 'lib/simple_analytics_rails/configuration.rb', line 48

def onload_callback
  @onload_callback
end

#sa_globalObject

Returns the value of attribute sa_global.



18
19
20
# File 'lib/simple_analytics_rails/configuration.rb', line 18

def sa_global
  @sa_global
end

Instance Method Details

#auto_collect?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/simple_analytics_rails/configuration.rb', line 44

def auto_collect?
  @auto_collect
end

#collect_dnt?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/simple_analytics_rails/configuration.rb', line 25

def collect_dnt?
  @collect_dnt
end

#custom_sa_global?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/simple_analytics_rails/configuration.rb', line 20

def custom_sa_global?
  @sa_global != "sa_event"
end

#enabled?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/simple_analytics_rails/configuration.rb', line 30

def enabled?
  @enabled
end

#noscript_domainObject



39
40
41
# File 'lib/simple_analytics_rails/configuration.rb', line 39

def noscript_domain
  @custom_domain.present? ? @custom_domain : "queue.simpleanalyticscdn.com"
end

#onload_callback?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/simple_analytics_rails/configuration.rb', line 49

def onload_callback?
  @onload_callback.present?
end

#script_domainObject



35
36
37
# File 'lib/simple_analytics_rails/configuration.rb', line 35

def script_domain
  @custom_domain.present? ? @custom_domain : "scripts.simpleanalyticscdn.com"
end

#to_hObject



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/simple_analytics_rails/configuration.rb', line 53

def to_h
  {
    sa_global: custom_sa_global? ? sa_global : nil,
    auto_collect: auto_collect? ? nil : "false",
    hostname: @hostname,
    mode: @mode,
    collect_dnt: collect_dnt? ? "true" : nil,
    ignore_pages: @ignore_pages,
    turbolinks_track: turbolinks_track
  }.compact.reject { |_key, value| value.blank? }
end