class Notifly::Models::Options::Fly

Attributes

after[RW]
before[RW]
data[RW]
if[RW]
kind[RW]
mail[RW]
receiver[RW]
sender[RW]
target[RW]
template[RW]
then[RW]
unless[RW]

Public Class Methods

new(options={}) click to toggle source
# 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

Public Instance Methods

attributes() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/notifly/models/options/fly.rb, line 13
def hook
  if @before.nil?
    :after
  else
    :before
  end
end
merge(fly) click to toggle source
# 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() click to toggle source
# File lib/notifly/models/options/fly.rb, line 21
def method_name
  self.send(hook)
end