Class: WebMerge::Notification

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/web_merge/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to: required(:to), from: required(:from), subject: "WebMerge Notification", security: WebMerge::Constants::SECURITY_LEVEL_LOW, html: nil, password: nil) ⇒ Notification

Returns a new instance of Notification.



12
13
14
15
16
17
18
19
# File 'lib/web_merge/notification.rb', line 12

def initialize(to: required(:to), from: required(:from), subject: "WebMerge Notification", security: WebMerge::Constants::SECURITY_LEVEL_LOW, html: nil, password: nil)
  @to = to
  @from = from
  @subject = subject
  @security = security
  @html = html
  @password = password
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



5
6
7
# File 'lib/web_merge/notification.rb', line 5

def from
  @from
end

#htmlObject

Returns the value of attribute html.



5
6
7
# File 'lib/web_merge/notification.rb', line 5

def html
  @html
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/web_merge/notification.rb', line 5

def password
  @password
end

#securityObject

Returns the value of attribute security.



5
6
7
# File 'lib/web_merge/notification.rb', line 5

def security
  @security
end

#subjectObject

Returns the value of attribute subject.



5
6
7
# File 'lib/web_merge/notification.rb', line 5

def subject
  @subject
end

#toObject

Returns the value of attribute to.



5
6
7
# File 'lib/web_merge/notification.rb', line 5

def to
  @to
end

Instance Method Details

#as_form_dataObject



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

def as_form_data
  request_params = {
    to: to,
    from: from,
    subject: subject,
    html: html,
    security: security
  }
  request_params.merge!(password: password) if requires_password?
  request_params
end

#requires_password?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/web_merge/notification.rb', line 21

def requires_password?
  security == WebMerge::Constants::SECURITY_LEVEL_MEDIUM || security == WebMerge::Constants::SECURITY_LEVEL_HIGH
end