Class: Notifly::Models::Options::Fly

Inherits:
Object
  • Object
show all
Defined in:
lib/notifly/models/options/fly.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  options = options.fetch(:default_values, options)
  options.each { |key, value| try "#{key}=", value }
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def after
  @after
end

#beforeObject

Returns the value of attribute before.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def before
  @before
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def data
  @data
end

#ifObject

Returns the value of attribute if.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def if
  @if
end

#kindObject

Returns the value of attribute kind.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def kind
  @kind
end

#mailObject

Returns the value of attribute mail.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def mail
  @mail
end

#receiverObject

Returns the value of attribute receiver.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def receiver
  @receiver
end

#senderObject

Returns the value of attribute sender.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def sender
  @sender
end

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def target
  @target
end

#templateObject

Returns the value of attribute template.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def template
  @template
end

#thenObject

Returns the value of attribute then.



5
6
7
# File 'lib/notifly/models/options/fly.rb', line 5

def then
  @then
end

#unlessObject

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

#attributesObject



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_typeObject



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

#hookObject



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

Raises:

  • (TypeError)


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_nameObject



21
22
23
# File 'lib/notifly/models/options/fly.rb', line 21

def method_name
  self.send(hook)
end