Module: Airship::Attachment::Padrino::ClassMethods

Includes:
Extensions::Padrino
Defined in:
lib/airship/attachment/padrino.rb

Constant Summary

Constants included from Extensions::Padrino

Extensions::Padrino::ROUTE_PRIORITY

Instance Method Summary collapse

Methods included from Extensions::Padrino

#route

Instance Method Details

#construct_filter(*args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/airship/attachment/padrino.rb', line 14

def construct_filter(*args, &block)
  options = args.last.is_a?(Hash) ? args.pop : {}
  name = options.delete(:to)

  if name.instance_of?(Symbol) && !block_given?
    unbound_method = instance_method(name) rescue undefined_method(name)
    block = proc{ unbound_method.bind(self).call }
  end

  except = options.key?(:except) && Array(options.delete(:except))
  raise("You cannot use except with other options specified") if except && (!args.empty? || !options.empty?)
  options = except.last.is_a?(Hash) ? except.pop : {} if except
  ::Padrino::Filter.new(!except, @_controller, options, Array(except || args), &block)
end

#generate_unbound_method(verb, path, options, &block) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/airship/attachment/padrino.rb', line 29

def generate_unbound_method(verb, path, options, &block)
  name = options.delete(:to)
  if name.instance_of?(Symbol) && !block_given?
    instance_method(name) rescue undefined_method(name)
  else
    super
  end
end