Class: AhoyCaptain::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ahoy_captain/configuration.rb', line 8

def initialize
  @goals = GoalCollection.new
  @funnels = FunnelCollection.new
  @theme = "dark"
  @ranges = ::AhoyCaptain::PeriodCollection.load_default
  @cache = ActiveSupport::OrderedOptions.new.tap do |option|
    option.enabled = false
    option.store = Rails.cache
    option.ttl = 1.minute
  end
  @models = ActiveSupport::OrderedOptions.new.tap do |option|
    option.event = "::Ahoy::Event"
    option.visit = "::Ahoy::Visit"
  end
  @event = ActiveSupport::OrderedOptions.new.tap do |option|
    option.view_name = "$view"
    option.url_column = "CONCAT(#{@models.event.parameterize.tableize}.properties->>'controller', '#', #{@models.event.parameterize.tableize}.properties->>'action')"
    option.url_exists = "JSONB_EXISTS(#{@models.event.parameterize.tableize}.properties, 'controller') AND JSONB_EXISTS(#{@models.event.parameterize.tableize}.properties, 'action')"
  end
  @filters = FiltersConfiguration.load_default
  @predicate_labels = {
    eq: 'equals',
    not_eq: 'not equals',
    cont: 'contains',
    in: 'in',
    not_in: 'not in',
  }

  @realtime_interval = 30.seconds
  @disabled_widgets = []
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def cache
  @cache
end

#disabled_widgetsObject

Returns the value of attribute disabled_widgets.



6
7
8
# File 'lib/ahoy_captain/configuration.rb', line 6

def disabled_widgets
  @disabled_widgets
end

#eventObject (readonly)

Returns the value of attribute event.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def event
  @event
end

#filtersObject (readonly)

Returns the value of attribute filters.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def filters
  @filters
end

#funnelsObject (readonly)

Returns the value of attribute funnels.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def funnels
  @funnels
end

#goalsObject (readonly)

Returns the value of attribute goals.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def goals
  @goals
end

#modelsObject (readonly)

Returns the value of attribute models.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def models
  @models
end

#predicate_labelsObject (readonly)

Returns the value of attribute predicate_labels.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def predicate_labels
  @predicate_labels
end

#rangesObject (readonly)

Returns the value of attribute ranges.



7
8
9
# File 'lib/ahoy_captain/configuration.rb', line 7

def ranges
  @ranges
end

#realtime_intervalObject

Returns the value of attribute realtime_interval.



6
7
8
# File 'lib/ahoy_captain/configuration.rb', line 6

def realtime_interval
  @realtime_interval
end

#themeObject

Returns the value of attribute theme.



6
7
8
# File 'lib/ahoy_captain/configuration.rb', line 6

def theme
  @theme
end

#view_nameObject

Returns the value of attribute view_name.



6
7
8
# File 'lib/ahoy_captain/configuration.rb', line 6

def view_name
  @view_name
end

Instance Method Details

#funnel(id, &block) ⇒ Object



47
48
49
50
51
52
# File 'lib/ahoy_captain/configuration.rb', line 47

def funnel(id, &block)
  instance = Funnel.new
  instance.id = id
  instance.instance_exec(&block)
  @funnels.register(instance)
end

#goal(id, &block) ⇒ Object



40
41
42
43
44
45
# File 'lib/ahoy_captain/configuration.rb', line 40

def goal(id, &block)
  instance = Goal.new
  instance.id = id
  instance.instance_exec(&block)
  @goals.register(instance)
end