Class: Courier::OwnerSetting

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/courier/owner_setting.rb

Instance Method Summary collapse

Instance Method Details

#disabled?(template, service, args = {}) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/courier/owner_setting.rb', line 42

def disabled?(template, service, args={})
  get(template, service)==:off
end

#enabled?(template, service, args = {}) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/courier/owner_setting.rb', line 38

def enabled?(template, service, args={})
  get(template, service)==:on
end

#get(template, service) ⇒ Object



31
32
33
34
35
36
# File 'lib/courier/owner_setting.rb', line 31

def get(template, service)
  service = Courier.service(service) if service.is_a? Symbol
  template = Courier.template(template) if template.is_a? Symbol
  val = settings_of_template(template)[service.name]
  val || template.get(service)
end

#set(template, service, val = nil) ⇒ Object



25
26
27
28
29
# File 'lib/courier/owner_setting.rb', line 25

def set(template, service, val=nil)
  service = Courier.service(service) if service.is_a? Symbol
  raise 'Cant use value as argument when block given' if block_given? and val
  settings_of_template(template)[service.name] = block_given? ? yield : val
end

#settings_of_template(template) ⇒ Object



20
21
22
23
# File 'lib/courier/owner_setting.rb', line 20

def settings_of_template(template)
  template = Courier.template(template) if template.is_a? Symbol
  settings[template.name]||={}
end