Class: Sinicum::Jcr::JcrConfiguration
- Inherits:
-
Object
- Object
- Sinicum::Jcr::JcrConfiguration
- Defined in:
- lib/sinicum/jcr/jcr_configuration.rb
Overview
Public: Handles the configuration for accessing the JCR server.
Constant Summary collapse
- DEFAULT_HOST =
"localhost"
- DEFAULT_PORT =
"8080"
- DEFAULT_PROTOCOL =
"http"
- DEFAULT_PREFIX =
"/sinicum-rest"
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #base_proto_host_port ⇒ Object
- #base_url ⇒ Object
-
#initialize(params = {}) ⇒ JcrConfiguration
constructor
A new instance of JcrConfiguration.
- #port ⇒ Object
- #port=(port) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ JcrConfiguration
Returns a new instance of JcrConfiguration.
11 12 13 14 15 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 11 def initialize(params = {}) [:host, :port, :protocol, :path_prefix, :username, :password].each do |param| send("#{param}=", params[param]) if params.key?(param) end end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 5 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 5 def password @password end |
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
5 6 7 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 5 def path_prefix @path_prefix end |
#protocol ⇒ Object
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 5 def protocol @protocol end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 5 def username @username end |
Instance Method Details
#base_proto_host_port ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 53 def base_proto_host_port unless defined?(@base_proto_host_port) base_proto_host_port = protocol.dup base_proto_host_port << "://" base_proto_host_port << (host || DEFAULT_HOST) unless (port.to_i == 80 && protocol == "http") || port.to_i == 443 && protocol == "https" base_proto_host_port << ":" << port end @base_proto_host_port = base_proto_host_port end @base_proto_host_port end |
#base_url ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 44 def base_url unless defined?(@base_url) base_url = base_proto_host_port.dup base_url << (path_prefix || DEFAULT_PREFIX) @base_url = base_url end @base_url end |
#port ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 26 def port port = @port unless port if protocol == "http" port = "80" elsif protocol == "https" port = "443" else port = "" end end port end |
#port=(port) ⇒ Object
22 23 24 |
# File 'lib/sinicum/jcr/jcr_configuration.rb', line 22 def port=(port) @port = port.to_s end |