Class: RedisUiRails::RedisInstance
- Inherits:
-
Object
- Object
- RedisUiRails::RedisInstance
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/redis_ui_rails/redis_instance.rb
Constant Summary collapse
- REQUIRED_OPTIONS_KEYS =
[:url, :name, :id].freeze
Instance Attribute Summary collapse
-
#actual_url ⇒ Object
Returns the value of attribute actual_url.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#resource_links ⇒ Object
Returns the value of attribute resource_links.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(hash) ⇒ RedisInstance
constructor
A new instance of RedisInstance.
- #url(unredacted: false) ⇒ Object
Constructor Details
#initialize(hash) ⇒ RedisInstance
Returns a new instance of RedisInstance.
10 11 12 13 14 15 16 17 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 10 def initialize(hash) self. = hash.symbolize_keys self.actual_url = [:url] self.name = [:name] self.id = [:id] self.resource_links = [:resource_links] || [] self.enabled = .key?(:enabled) ? [:enabled] : true end |
Instance Attribute Details
#actual_url ⇒ Object
Returns the value of attribute actual_url.
18 19 20 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 18 def actual_url @actual_url end |
#id ⇒ Object
Returns the value of attribute id.
18 19 20 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 18 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 18 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
18 19 20 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 18 def @options end |
#resource_links ⇒ Object
Returns the value of attribute resource_links.
18 19 20 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 18 def resource_links @resource_links end |
Instance Method Details
#enabled? ⇒ Boolean
20 21 22 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 20 def enabled? enabled end |
#url(unredacted: false) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/redis_ui_rails/redis_instance.rb', line 24 def url(unredacted: false) return actual_url if unredacted uri = URI(actual_url) uri.host = uri.host.to_s.tr("0-9", "*") unless /localhost/.match?(uri.host.to_s) uri.password = "*" if uri.user uri.to_s end |