Class: Notifly::Models::Options::Fly
- Inherits:
-
Object
- Object
- Notifly::Models::Options::Fly
- Defined in:
- lib/notifly/models/options/fly.rb
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#before ⇒ Object
Returns the value of attribute before.
-
#data ⇒ Object
Returns the value of attribute data.
-
#if ⇒ Object
Returns the value of attribute if.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#mail ⇒ Object
Returns the value of attribute mail.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#target ⇒ Object
Returns the value of attribute target.
-
#template ⇒ Object
Returns the value of attribute template.
-
#then ⇒ Object
Returns the value of attribute then.
-
#unless ⇒ Object
Returns the value of attribute unless.
Instance Method Summary collapse
- #attributes ⇒ Object
- #get_mail_type ⇒ Object
- #hook ⇒ Object
-
#initialize(options = {}) ⇒ Fly
constructor
A new instance of Fly.
- #merge(fly) ⇒ Object
- #method_name ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Fly
Returns a new instance of Fly.
8 9 10 11 |
# File 'lib/notifly/models/options/fly.rb', line 8 def initialize(={}) = .fetch(:default_values, ) .each { |key, value| try "#{key}=", value } end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def after @after end |
#before ⇒ Object
Returns the value of attribute before.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def before @before end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def data @data end |
#if ⇒ Object
Returns the value of attribute if.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def if @if end |
#kind ⇒ Object
Returns the value of attribute kind.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def kind @kind end |
#mail ⇒ Object
Returns the value of attribute mail.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def mail @mail end |
#receiver ⇒ Object
Returns the value of attribute receiver.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def receiver @receiver end |
#sender ⇒ Object
Returns the value of attribute sender.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def sender @sender end |
#target ⇒ Object
Returns the value of attribute target.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def target @target end |
#template ⇒ Object
Returns the value of attribute template.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def template @template end |
#then ⇒ Object
Returns the value of attribute then.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def then @then end |
#unless ⇒ Object
Returns the value of attribute unless.
5 6 7 |
# File 'lib/notifly/models/options/fly.rb', line 5 def unless @unless end |
Instance Method Details
#attributes ⇒ Object
25 26 27 28 29 |
# File 'lib/notifly/models/options/fly.rb', line 25 def attributes no_attrs = [hook, :if, :unless, :mail, :then] attrs = instance_values.reject { |key| no_attrs.include? key.to_sym } attrs.merge({mail: get_mail_type}) end |
#get_mail_type ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/notifly/models/options/fly.rb', line 37 def get_mail_type if mail == true :always elsif mail.present? and mail[:only] :only else :never end end |
#hook ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/notifly/models/options/fly.rb', line 13 def hook if @before.nil? :after else :before end end |
#merge(fly) ⇒ Object
31 32 33 34 35 |
# File 'lib/notifly/models/options/fly.rb', line 31 def merge(fly) raise TypeError, "#{fly} is not a Fly" unless fly.is_a? self.class Notifly::Models::Options::Fly.new instance_values.merge(fly.instance_values) end |
#method_name ⇒ Object
21 22 23 |
# File 'lib/notifly/models/options/fly.rb', line 21 def method_name self.send(hook) end |