Class: Irumugam::Service
- Inherits:
-
Object
- Object
- Irumugam::Service
- Defined in:
- lib/irumugam/service.rb
Instance Attribute Summary collapse
-
#after_blocks ⇒ Object
Returns the value of attribute after_blocks.
-
#before_blocks ⇒ Object
Returns the value of attribute before_blocks.
-
#block ⇒ Object
Returns the value of attribute block.
-
#name ⇒ Object
Returns the value of attribute name.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#rest_end_point ⇒ Object
Returns the value of attribute rest_end_point.
-
#test_host ⇒ Object
Returns the value of attribute test_host.
Instance Method Summary collapse
- #after(type = :each, &after_block) ⇒ Object
- #before(type = :each, &before_block) ⇒ Object
- #end_point(name) ⇒ Object
- #host(val) ⇒ Object
- #http_method(method, path, options, contract_block) ⇒ Object
-
#initialize(name, service_block) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(name, service_block) ⇒ Service
Returns a new instance of Service.
4 5 6 7 8 9 10 |
# File 'lib/irumugam/service.rb', line 4 def initialize(name, service_block) @name, @block = name, service_block @before_blocks = {} @after_blocks = {} @paths = ServiceRegistry.instance.paths instance_eval &service_block end |
Instance Attribute Details
#after_blocks ⇒ Object
Returns the value of attribute after_blocks.
3 4 5 |
# File 'lib/irumugam/service.rb', line 3 def after_blocks @after_blocks end |
#before_blocks ⇒ Object
Returns the value of attribute before_blocks.
3 4 5 |
# File 'lib/irumugam/service.rb', line 3 def before_blocks @before_blocks end |
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/irumugam/service.rb', line 3 def block @block end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/irumugam/service.rb', line 3 def name @name end |
#paths ⇒ Object
Returns the value of attribute paths.
3 4 5 |
# File 'lib/irumugam/service.rb', line 3 def paths @paths end |
#rest_end_point ⇒ Object
Returns the value of attribute rest_end_point.
3 4 5 |
# File 'lib/irumugam/service.rb', line 3 def rest_end_point @rest_end_point end |
#test_host ⇒ Object
Returns the value of attribute test_host.
3 4 5 |
# File 'lib/irumugam/service.rb', line 3 def test_host @test_host end |
Instance Method Details
#after(type = :each, &after_block) ⇒ Object
14 15 16 |
# File 'lib/irumugam/service.rb', line 14 def after(type=:each, &after_block) after_blocks[type] = after_block end |
#before(type = :each, &before_block) ⇒ Object
11 12 13 |
# File 'lib/irumugam/service.rb', line 11 def before(type=:each, &before_block) before_blocks[type] = before_block end |
#end_point(name) ⇒ Object
17 18 19 |
# File 'lib/irumugam/service.rb', line 17 def end_point(name) @rest_end_point = name end |
#host(val) ⇒ Object
20 21 22 |
# File 'lib/irumugam/service.rb', line 20 def host(val) @test_host=val end |
#http_method(method, path, options, contract_block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/irumugam/service.rb', line 29 def http_method(method,path,,contract_block) defaults = {:accept=>"application/json", :method=>method, :path=>path, :test_host => @test_host, :params=>{}, :block=>contract_block, :service=>self} defaults.merge!() paths[path] ||= [] paths[path] << Contract.new(defaults) end |