module EOTS

Constants

NON_FIELD_ITEMS

need a better short name for this… stuff we want to let the dev pass in the email_kind declaration, either as an option or in the block, other than fields.…

STANDARD_FIELDS

standard fields you'd see in any email

VERSION

Public Class Methods

email_kind(name, options={}) { || ... } click to toggle source
# File lib/eots.rb, line 17
def self.email_kind(name, options={}, &block)
  kind = create_email_kind(name, options)
  @@kind_stack.push kind
  yield if block_given?
  @@kind_stack.pop
end
field(name, label, options={}) click to toggle source
# File lib/eots.rb, line 24
def self.field(name, label, options={})
  @@kind_stack.last.add_field(name, label, options)
end
find_kind(kind_name) click to toggle source
# File lib/eots.rb, line 28
def self.find_kind(kind_name)
  kind = @@kind_hash[kind_name]
  unless kind
    raise(EOTS::EmailKind:: NotFoundError,
          "Unknown email kind '#{kind_name}'")
  end
  kind
end

Private Class Methods

create_email_kind(name, options) click to toggle source
# File lib/eots.rb, line 52
def self.create_email_kind(name, options)
  raise(EmailKind::AlreadyDefinedError, "Email kind #{name} is already defined") if @@kind_hash[name]
  @@kind_hash[name] = EOTS::EmailKind.new(name, @@kind_stack.last, options)
end
reset() click to toggle source

declare/init innards this way so we can reset them in tests

# File lib/eots.rb, line 46
def self.reset
  @@kind_stack = []
  @@kind_hash = {}
end