Class: ClickSession::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#failure_callback_urlObject

Returns the value of attribute failure_callback_url.



19
20
21
# File 'lib/click_session/configuration.rb', line 19

def failure_callback_url
  @failure_callback_url
end

#serializer_classObject

Returns the value of attribute serializer_class.



19
20
21
# File 'lib/click_session/configuration.rb', line 19

def serializer_class
  @serializer_class
end

#success_callback_urlObject

Returns the value of attribute success_callback_url.



19
20
21
# File 'lib/click_session/configuration.rb', line 19

def success_callback_url
  @success_callback_url
end

Instance Method Details

#driver_clientObject



87
88
89
# File 'lib/click_session/configuration.rb', line 87

def driver_client
  @driver_client ||= :poltergeist
end

#driver_client=(client) ⇒ Object



91
92
93
# File 'lib/click_session/configuration.rb', line 91

def driver_client=(client)
  @driver_client = client
end

#enable_screenshot=(enable) ⇒ Object



99
100
101
# File 'lib/click_session/configuration.rb', line 99

def enable_screenshot=(enable)
  @screenshot_enabled = enable
end

#model_classObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/click_session/configuration.rb', line 23

def model_class
  if @model_class == nil
    raise NameError.new(<<-ERROR.strip_heredoc, 'model_class')
      To use ClickSession, you must define the name of the active model
      you want ClickSession to operate on.
      See https://github.com/talltorp/click_session for more information.
    ERROR
  end

  @model_class.constantize
end

#model_class=(klass) ⇒ Object



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

def model_class=(klass)
  @model_class = klass.to_s
end

#notifier_classObject



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/click_session/configuration.rb', line 69

def notifier_class
  @notifier_class ||= "ClickSession::Notifier"
  constantized_notifier = @notifier_class.constantize

  if notifier_class_violates_interface(constantized_notifier)
    raise ArgumentError.new(<<-ERROR.strip_heredoc)
      Your custom notifier must inherit ClickSession::Notifier
      See https://github.com/talltorp/click_session
    ERROR
  end

  constantized_notifier
end

#notifier_class=(klass) ⇒ Object



83
84
85
# File 'lib/click_session/configuration.rb', line 83

def notifier_class=(klass)
  @notifier_class = klass.to_s
end

#runner_classObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/click_session/configuration.rb', line 39

def runner_class
  @runner_class ||=
    begin
      if Kernel.const_defined?(:ClickSessionRunner)
        "ClickSessionRunner"
      else
        raise NameError.new(<<-ERROR.strip_heredoc, 'ClickSessionRunner')
          To use ClickSession, you must either define `ClickSessionRunner` or configure a
          different processor. See https://github.com/talltorp/click_session for
          more information.
        ERROR
      end
    end

  @runner_class.constantize
end

#runner_class=(klass) ⇒ Object



56
57
58
# File 'lib/click_session/configuration.rb', line 56

def runner_class=(klass)
  @runner_class = klass.to_s
end

#screenshotObject



103
104
105
106
107
108
109
110
111
112
# File 'lib/click_session/configuration.rb', line 103

def screenshot
  if @screenshot == nil
    raise ArgumentError.new("In order to save screenshots, you need to configure \
      the information.
      https://github.com/talltorp/click_session#optional-configurations-and-extentions
      ")
  end

  @screenshot
end

#screenshot=(screenshot) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/click_session/configuration.rb', line 114

def screenshot=(screenshot)
  if screenshot[:s3_bucket] == nil
    raise ArgumentError.new("The s3_bucket is required")
  end

  if screenshot[:s3_key_id] == nil
    raise ArgumentError.new("The s3_key_id is required")
  end

  if screenshot[:s3_access_key] == nil
    raise ArgumentError.new("The s3_access_key is required")
  end

  @screenshot = screenshot
end

#screenshot_enabled?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/click_session/configuration.rb', line 95

def screenshot_enabled?
  @screenshot_enabled ||= false
end