Sha256: 023308b3f676fa836545c0236e318cedf0b10b2ea54e3ab90610be64c2f5cda3
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
# -*- coding: utf-8 -*- class Courier::Template::Base AvailableValues = [:on, :off, :disabled] attr_accessor :name, :defaults def initialize(args) self.name = args[:name].to_sym or raise 'no template name defined' self.defaults={} end def get_text(service, args) args[:scope]=[:courier, :services, service.to_s, :templates] unless args[:scope] args[:cascade]=true unless args.has_key? :cascade I18n::translate(name, args ) end def get(service) service = Courier.service(service) if service.is_a?(Symbol) name = service.name.to_sym raise "Not defined default value for #{service} in template #{self}" unless defaults.has_key? name defaults[name] end def set(service, val) service = Courier.service(service) if service.is_a?(Symbol) defaults[service.name.to_sym] = check_val(val) end def to_s name.to_s end def to_label I18n::translate(name, :scope=>[:courier,:templates] ) end def key name end private def check_val(val) raise "Value must be one of #{AvailableValues.join(', ')}" unless AvailableValues.include? val val end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
courier-0.2.4 | lib/courier/template/base.rb |
courier-0.2.3 | lib/courier/template/base.rb |
courier-0.2.1 | lib/courier/template/base.rb |
courier-0.2.0 | lib/courier/template/base.rb |