Class: Pushr::Feedback
- Inherits:
-
Object
- Object
- Pushr::Feedback
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/pushr/feedback.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .create(attributes = {}) ⇒ Object
- .create!(attributes = {}) ⇒ Object
- .instantiate(config) ⇒ Object
- .next(timeout = 3) ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Feedback
constructor
A new instance of Feedback.
- #save ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Feedback
Returns a new instance of Feedback.
11 12 13 14 15 |
# File 'lib/pushr/feedback.rb', line 11 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) if respond_to?("#{name}=") end end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5 6 7 |
# File 'lib/pushr/feedback.rb', line 5 def app @app end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/pushr/feedback.rb', line 5 def type @type end |
Class Method Details
.create(attributes = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/pushr/feedback.rb', line 26 def self.create(attributes = {}) m = new(attributes) m.save m end |
.create!(attributes = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/pushr/feedback.rb', line 32 def self.create!(attributes = {}) m = new(attributes) unless m.save raise Pushr::Error::RecordInvalid end m end |
.instantiate(config) ⇒ Object
51 52 53 54 55 |
# File 'lib/pushr/feedback.rb', line 51 def self.instantiate(config) hsh = ::MultiJson.load(config) klass = hsh['type'].split('::').reduce(Object) { |a, e| a.const_get e } klass.new(hsh) end |
Instance Method Details
#save ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/pushr/feedback.rb', line 17 def save if valid? Pushr::Core.redis { |conn| conn.rpush('pushr:feedback', to_json) } return true else return false end end |
#to_json ⇒ Object
40 41 42 |
# File 'lib/pushr/feedback.rb', line 40 def to_json MultiJson.dump(to_hash) end |