Module: Transit::Model::Hooks

Defined in:
lib/transit/model/hooks.rb

Instance Method Summary collapse

Instance Method Details

#auto_incrementObject

Provide auto-incrementing functionality for any model



24
25
26
# File 'lib/transit/model/hooks.rb', line 24

def auto_increment
  include Transit::Model::AutoIncrement
end

#deliver_as(type) ⇒ Object



6
7
8
9
10
# File 'lib/transit/model/hooks.rb', line 6

def deliver_as(type)
  scope = type.to_s.classify
  include Transit::Package.const_get(scope)
  Transit.track(self, type.to_sym)
end

#deliver_with(*opts) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/transit/model/hooks.rb', line 12

def deliver_with(*opts)
  opts.map(&:to_s).map(&:classify).each do |t|
    begin
      include Transit::Model.const_get(t.pluralize)          
    rescue NameError
      raise Transit::Errors::ResourceNotFound.new("You called deliver_with #{t.underscore} but no resource called #{t.pluralize} was found.")
    end
  end
  self.delivery_options |= opts.map!(&:to_s)
end