module Airship::Attachment::Padrino::ClassMethods

Public Instance Methods

construct_filter(*args, &block) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

undefined_method(name) click to toggle source
# File lib/airship/attachment/padrino.rb, line 40
def undefined_method(name)
  raise UndefinedMethod, "undefined method `#{name}`."
end