Class: BERTRPC::Service
- Inherits:
-
Object
- Object
- BERTRPC::Service
- Defined in:
- lib/bertrpc/service.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #call(options = nil) ⇒ Object
- #cast(options = nil) ⇒ Object
-
#initialize(host, port, timeout = nil) ⇒ Service
constructor
A new instance of Service.
-
#verify_options(options) ⇒ Object
private.
Constructor Details
#initialize(host, port, timeout = nil) ⇒ Service
Returns a new instance of Service.
5 6 7 8 9 |
# File 'lib/bertrpc/service.rb', line 5 def initialize(host, port, timeout = nil) @host = host @port = port @timeout = timeout end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/bertrpc/service.rb', line 3 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/bertrpc/service.rb', line 3 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/bertrpc/service.rb', line 3 def timeout @timeout end |
Instance Method Details
#call(options = nil) ⇒ Object
11 12 13 14 |
# File 'lib/bertrpc/service.rb', line 11 def call( = nil) () Request.new(self, :call, ) end |
#cast(options = nil) ⇒ Object
16 17 18 19 |
# File 'lib/bertrpc/service.rb', line 16 def cast( = nil) () Request.new(self, :cast, ) end |
#verify_options(options) ⇒ Object
private
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bertrpc/service.rb', line 23 def () (||{}).each do |key, value| case key when :stream unless (String === value and File.file?(value)) raise InvalidOption.new("Valid :stream args are IO or path") end when :case unless value[0] == :validation && value[1].is_a?(String) raise InvalidOption.new("Valid :cache args are [:validation, String]") end else raise InvalidOption.new("Valid options are :cache and :stream") end end end |