Class: Rester::Service::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/rester/service/request.rb

Constant Summary collapse

CUSTOM_FIELDS =
['correlation_id', 'producer_name',
'consumer_name'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



12
13
14
15
# File 'lib/rester/service/request.rb', line 12

def initialize(env)
  super
  _parse_path if valid?
end

Instance Attribute Details

#object_chainObject (readonly)

Returns the value of attribute object_chain.



7
8
9
# File 'lib/rester/service/request.rb', line 7

def object_chain
  @object_chain
end

#versionObject (readonly)

Returns the value of attribute version.



6
7
8
# File 'lib/rester/service/request.rb', line 6

def version
  @version
end

Instance Method Details

#each_resourceObject



21
22
23
24
25
26
27
28
29
# File 'lib/rester/service/request.rb', line 21

def each_resource
  return unless (chain = object_chain)

  loop do
    name, id, *chain = chain
    yield name, id
    break if chain.empty?
  end
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rester/service/request.rb', line 17

def valid?
  path.length < 256 && %r{\A/v\d+/(\w+/?)+\z}.match(path)
end