Module: Allowed::Limit::ClassMethods

Defined in:
lib/allowed/limit.rb

Instance Method Summary collapse

Instance Method Details

#allow(limit, options = {}, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/allowed/limit.rb', line 10

def allow(limit, options = {}, &block)
  if block_given?
    options[:callback] = block
  end

  self._throttles ||= []
  self._throttles  << Throttle.new(limit, options)

  validate :validate_throttles, on: :create

  after_rollback :handle_throttles, on: :create
end