Class: Carnivore::Http::PointBuilder::Endpoint

Inherits:
Object
  • Object
show all
Includes:
Utils::Logging, Utils::Params, Zoidberg::SoftShell, Zoidberg::Supervise
Defined in:
lib/carnivore-http/point_builder.rb

Overview

End point

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, endpoint, block) ⇒ Endpoint

Create new endoint

Parameters:

  • type (Symbol)

    request type (:get, :put, etc.)

  • endpoint (String, Regexp)

    request path matcher

  • block (Proc)

    action to run on match



29
30
31
32
33
# File 'lib/carnivore-http/point_builder.rb', line 29

def initialize(type, endpoint, block)
  @endpoint = endpoint
  @type = type
  define_singleton_method(:wrapped_execute, &block)
end

Instance Attribute Details

#endpointString, Regexp (readonly)

Returns request path matcher.

Returns:

  • (String, Regexp)

    request path matcher



20
21
22
# File 'lib/carnivore-http/point_builder.rb', line 20

def endpoint
  @endpoint
end

#typeSymbol (readonly)

Returns request type (:get, :put, etc.).

Returns:

  • (Symbol)

    request type (:get, :put, etc.)



22
23
24
# File 'lib/carnivore-http/point_builder.rb', line 22

def type
  @type
end

Instance Method Details

#execute(*args) ⇒ Object

Execute action on match

Parameters:

  • args (Object)

    argument list



38
39
40
41
42
43
44
45
46
# File 'lib/carnivore-http/point_builder.rb', line 38

def execute(*args)
  begin
    wrapped_execute(*args)
  rescue => e
    error "Unexpected error encountered! #{e.class}: #{e}"
    debug "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
    abort e
  end
end

#inspectString

Returns instance inspection.

Returns:

  • (String)

    instance inspection



54
55
56
# File 'lib/carnivore-http/point_builder.rb', line 54

def inspect
  "<Endpoint[#{endpoint}] type=#{type} objectid=#{self.object_id}>"
end

#to_sString

Returns stringify.

Returns:

  • (String)

    stringify



49
50
51
# File 'lib/carnivore-http/point_builder.rb', line 49

def to_s
  "<Endpoint[#{endpoint}]>"
end