Module: Pasaporte::Controllers::Nicknames

Defined in:
lib/pasaporte.rb

Overview

Wraps the “get” and “post” with nickname passed in the path. When get_with_nick or post_with_nick is called, @nickname is already there.

Instance Method Summary collapse

Instance Method Details

#get(*extras) ⇒ Object



215
216
217
218
219
# File 'lib/pasaporte.rb', line 215

def get(*extras)
  raise "Nickname is required for this action" unless (@nickname = extras.shift)
  raise "#{self.class} does not respond to get_with_nick" unless respond_to?(:get_with_nick)
  get_with_nick(*extras)
end

#head(*extras) ⇒ Object



227
228
229
230
231
# File 'lib/pasaporte.rb', line 227

def head(*extras)
  raise "Nickname is required for this action" unless (@nickname = extras.shift)
  raise "#{self.class} does not respond to head_with_nick" unless respond_to?(:head_with_nick)
  head_with_nick(*extras)
end

#post(*extras) ⇒ Object



221
222
223
224
225
# File 'lib/pasaporte.rb', line 221

def post(*extras)
  raise "Nickname is required for this action" unless (@nickname = extras.shift)
  raise "#{self.class} does not respond to post_with_nick" unless respond_to?(:post_with_nick)
  post_with_nick(*extras)
end

#respond_to?(m, *whatever) ⇒ Boolean

So that we can define put_with_nick and Camping sees it as #put being available

Returns:

  • (Boolean)


234
235
236
# File 'lib/pasaporte.rb', line 234

def respond_to?(m, *whatever)
  super(m.to_sym) || super("#{m}_with_nick".to_sym)
end