Class: Syro::Deck

Inherits:
Object
  • Object
show all
Includes:
API
Defined in:
lib/syro.rb

Defined Under Namespace

Modules: API

Class Method Summary collapse

Methods included from API

#call, #capture, #consume, #default, #default_headers, #delete, #env, #finish!, #get, #halt, #handle, #head, #inbox, #match, #on, #options, #patch, #path, #post, #put, #req, #request_class, #res, #response_class, #root, #root?, #run

Class Method Details

.implement(&code) ⇒ Object

Attaches the supplied block to a subclass of Deck as #dispatch! Returns the subclassed Deck.



215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/syro.rb', line 215

def self.implement(&code)
  Class.new(self) do
    define_method(:dispatch!, code)
    private :dispatch!

    # Instead of calling inspect on this anonymous class,
    # defer to the superclass which is likely Syro::Deck.
    define_method(:inspect) do
      self.class.superclass.inspect
    end
  end
end