Module: FieldTest

Defined in:
lib/field_test/calculations.rb,
lib/field_test.rb,
lib/field_test/engine.rb,
lib/field_test/helpers.rb,
lib/field_test/version.rb,
lib/field_test/experiment.rb,
lib/field_test/participant.rb,
app/models/field_test/event.rb,
app/models/field_test/membership.rb,
app/controllers/field_test/base_controller.rb,
lib/generators/field_test/events_generator.rb,
lib/generators/field_test/install_generator.rb,
app/controllers/field_test/experiments_controller.rb,
app/controllers/field_test/memberships_controller.rb,
app/controllers/field_test/participants_controller.rb

Overview

Defined Under Namespace

Modules: Calculations, Generators, Helpers Classes: BaseController, Engine, Error, Event, Experiment, ExperimentNotFound, ExperimentsController, Membership, MembershipsController, Participant, ParticipantsController, UnknownParticipant

Constant Summary collapse

VERSION =
"0.2.3"

Class Method Summary collapse

Class Method Details

.cacheObject



27
28
29
# File 'lib/field_test.rb', line 27

def self.cache
  config["cache"]
end

.configObject



15
16
17
18
19
20
# File 'lib/field_test.rb', line 15

def self.config
  # reload in dev
  @config = nil if Rails.env.development?

  @config ||= YAML.load(ERB.new(File.read("config/field_test.yml")).result)
end

.events_supported?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/field_test.rb', line 31

def self.events_supported?
  unless defined?(@events_supported)
    connection = FieldTest::Membership.connection
    table_name = "field_test_events"
    @events_supported =
      if connection.respond_to?(:data_source_exists?)
        connection.data_source_exists?(table_name)
      else
        connection.table_exists?(table_name)
      end
  end
  @events_supported
end

.exclude_bots?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/field_test.rb', line 22

def self.exclude_bots?
  config = self.config # dev performance
  config["exclude"] && config["exclude"]["bots"]
end