Module: Navigable::Server::EndpointCommand::ClassMethods

Defined in:
lib/navigable/server/endpoint_command.rb

Instance Method Summary collapse

Instance Method Details

#corresponds_to(command_key) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/navigable/server/endpoint_command.rb', line 20

def corresponds_to(command_key)
  @corresponds_to_proc ||= Proc.new do |endpoint_klass, command_klass|
    endpoint_klass.executes(command_key)
    super(command_key)
  end

  setup_endpoint_command if ready_for_setup?
end

#ready_for_setup?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/navigable/server/endpoint_command.rb', line 35

def ready_for_setup?
  @responds_to_proc && @corresponds_to_proc
end

#responds_to(verb, path) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/navigable/server/endpoint_command.rb', line 12

def responds_to(verb, path)
  @responds_to_proc ||= Proc.new do |endpoint_klass|
    endpoint_klass.responds_to(verb, path)
  end

  setup_endpoint_command if ready_for_setup?
end

#setup_endpoint_commandObject



29
30
31
32
33
# File 'lib/navigable/server/endpoint_command.rb', line 29

def setup_endpoint_command
  endpoint_klass = Class.new { extend Navigable::Server::Endpoint }
  @responds_to_proc.call(endpoint_klass)
  @corresponds_to_proc.call(endpoint_klass, self)
end