Class: SafetyCone::Path
- Inherits:
-
Object
- Object
- SafetyCone::Path
- Defined in:
- app/models/safety_cone/path.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#key ⇒ Object
Returns the value of attribute key.
-
#message ⇒ Object
Returns the value of attribute message.
-
#method ⇒ Object
Returns the value of attribute method.
-
#name ⇒ Object
Returns the value of attribute name.
-
#redis ⇒ Object
Returns the value of attribute redis.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(key, params) ⇒ Path
constructor
A new instance of Path.
- #redis_key ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(key, params) ⇒ Path
Returns a new instance of Path.
7 8 9 10 11 12 13 14 15 16 |
# File 'app/models/safety_cone/path.rb', line 7 def initialize(key, params) @key = key @name = params[:name] @controller = params[:controller] @method = params[:action] @method = params[:method] = params[:message] @type = params[:type] || 'disabled' @redis = SafetyCone.redis end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def action @action end |
#controller ⇒ Object
Returns the value of attribute controller.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def controller @controller end |
#key ⇒ Object
Returns the value of attribute key.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def key @key end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def end |
#method ⇒ Object
Returns the value of attribute method.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def method @method end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def name @name end |
#redis ⇒ Object
Returns the value of attribute redis.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def redis @redis end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'app/models/safety_cone/path.rb', line 3 def type @type end |
Instance Method Details
#fetch ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/models/safety_cone/path.rb', line 23 def fetch stored_data = @redis.get(redis_key) if stored_data data = JSON.parse(stored_data) = data['message'] @type = data['type'] end end |
#redis_key ⇒ Object
33 34 35 |
# File 'app/models/safety_cone/path.rb', line 33 def redis_key "safety::cone::#{@key}" end |
#save ⇒ Object
18 19 20 21 |
# File 'app/models/safety_cone/path.rb', line 18 def save data = { message: , type: @type }.to_json @redis.set(redis_key, data) end |