Class: CouchbaseModelLogging::Client
- Inherits:
-
Object
- Object
- CouchbaseModelLogging::Client
- Defined in:
- lib/couchbase_model_logging/client.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#pool ⇒ Object
Returns the value of attribute pool.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #connection_options ⇒ Object
- #decorator_methods ⇒ Object
-
#initialize(options = { }) ⇒ Client
constructor
A new instance of Client.
- #method_missing(meth, *args, &blk) ⇒ Object
- #methods ⇒ Object
- #native_client ⇒ Object
- #respond_to?(meth) ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(options = { }) ⇒ Client
9 10 11 12 13 14 15 16 17 |
# File 'lib/couchbase_model_logging/client.rb', line 9 def initialize( = { }) self.protocol = [:protocol] || 'http' self.host = [:host] || 'localhost' self.port = [:port] || 8091 self.pool = [:pool] || 'default' self.bucket = [:bucket] || 'default' self.username = [:username] self.password = [:password] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/couchbase_model_logging/client.rb', line 39 def method_missing(meth, *args, &blk) if native_client.respond_to? meth call_info = caller[0] =~ /\/([\w\.]+):(\d+):in `(\w+)'/ ? "#{$1}:#{$2} #{$3}" : "unknown" #puts "mm : #{meth} : #{args.inspect} | from #{call_info}" native_client.send meth, *args, &blk else super end end |
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
7 8 9 |
# File 'lib/couchbase_model_logging/client.rb', line 7 def bucket @bucket end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/couchbase_model_logging/client.rb', line 7 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/couchbase_model_logging/client.rb', line 7 def password @password end |
#pool ⇒ Object
Returns the value of attribute pool.
7 8 9 |
# File 'lib/couchbase_model_logging/client.rb', line 7 def pool @pool end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/couchbase_model_logging/client.rb', line 7 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
7 8 9 |
# File 'lib/couchbase_model_logging/client.rb', line 7 def protocol @protocol end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/couchbase_model_logging/client.rb', line 7 def username @username end |
Instance Method Details
#connection_options ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/couchbase_model_logging/client.rb', line 23 def = {} [:bucket] = bucket [:username] = username if username [:password] = password if password end |
#decorator_methods ⇒ Object
49 |
# File 'lib/couchbase_model_logging/client.rb', line 49 alias_method :decorator_methods, :methods |
#methods ⇒ Object
51 52 53 |
# File 'lib/couchbase_model_logging/client.rb', line 51 def methods (decorator_methods + native_client.methods).uniq end |
#native_client ⇒ Object
31 32 33 |
# File 'lib/couchbase_model_logging/client.rb', line 31 def native_client @native_client ||= ::Couchbase.connect url, end |
#respond_to?(meth) ⇒ Boolean
35 36 37 |
# File 'lib/couchbase_model_logging/client.rb', line 35 def respond_to?(meth) native_client.respond_to?(meth) || super end |
#url ⇒ Object
19 20 21 |
# File 'lib/couchbase_model_logging/client.rb', line 19 def url "#{protocol}://#{host}:#{port}/pools/#{pool}" end |