Class: Smalltalk::Reply
- Inherits:
-
Object
- Object
- Smalltalk::Reply
- Defined in:
- lib/smalltalk/reply.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#message ⇒ Object
Returns the value of attribute message.
-
#sender ⇒ Object
Returns the value of attribute sender.
Instance Method Summary collapse
- #build! ⇒ Object
-
#initialize(params = {}) ⇒ Reply
constructor
A new instance of Reply.
- #validate ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Reply
Returns a new instance of Reply.
5 6 7 8 9 |
# File 'lib/smalltalk/reply.rb', line 5 def initialize(params = {}) self.sender = params[:sender] self. = params[:message] self.content = params[:content] end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/smalltalk/reply.rb', line 3 def content @content end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/smalltalk/reply.rb', line 3 def @message end |
#sender ⇒ Object
Returns the value of attribute sender.
3 4 5 |
# File 'lib/smalltalk/reply.rb', line 3 def sender @sender end |
Instance Method Details
#build! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/smalltalk/reply.rb', line 11 def build! validate reply = Smalltalk::Message.new reply.sender = sender reply.recipient = .sender reply.content = content reply.hidden = false reply.viewed = false reply.save! reply end |
#validate ⇒ Object
25 26 27 28 29 |
# File 'lib/smalltalk/reply.rb', line 25 def validate raise HTTPStatus::UnprocessableEntity, "No message specified!" if .blank? raise HTTPStatus::UnprocessableEntity, "No sender specified!" if sender.blank? raise HTTPStatus::UnprocessableEntity, "No message content was provided!" if content.blank? end |