Class: NewPostResult
- Inherits:
-
Object
- Object
- NewPostResult
- Includes:
- HasErrors
- Defined in:
- lib/new_post_result.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#message ⇒ Object
Returns the value of attribute message.
-
#pending_count ⇒ Object
Returns the value of attribute pending_count.
-
#post ⇒ Object
Returns the value of attribute post.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#reviewable ⇒ Object
Returns the value of attribute reviewable.
-
#route_to ⇒ Object
Returns the value of attribute route_to.
Attributes included from HasErrors
#conflict, #forbidden, #not_found
Instance Method Summary collapse
- #check_errors(arr) ⇒ Object
- #check_errors_from(obj) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(action, success = false) ⇒ NewPostResult
constructor
A new instance of NewPostResult.
- #queued_post ⇒ Object
- #success? ⇒ Boolean
Methods included from HasErrors
#add_error, #add_errors_from, #errors, #rollback_from_errors!, #rollback_with!, #validate_child
Constructor Details
#initialize(action, success = false) ⇒ NewPostResult
Returns a new instance of NewPostResult.
15 16 17 18 |
# File 'lib/new_post_result.rb', line 15 def initialize(action, success = false) @action = action @success = success end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
6 7 8 |
# File 'lib/new_post_result.rb', line 6 def action @action end |
#message ⇒ Object
Returns the value of attribute message.
13 14 15 |
# File 'lib/new_post_result.rb', line 13 def @message end |
#pending_count ⇒ Object
Returns the value of attribute pending_count.
11 12 13 |
# File 'lib/new_post_result.rb', line 11 def pending_count @pending_count end |
#post ⇒ Object
Returns the value of attribute post.
9 10 11 |
# File 'lib/new_post_result.rb', line 9 def post @post end |
#reason ⇒ Object
Returns the value of attribute reason.
8 9 10 |
# File 'lib/new_post_result.rb', line 8 def reason @reason end |
#reviewable ⇒ Object
Returns the value of attribute reviewable.
10 11 12 |
# File 'lib/new_post_result.rb', line 10 def reviewable @reviewable end |
#route_to ⇒ Object
Returns the value of attribute route_to.
12 13 14 |
# File 'lib/new_post_result.rb', line 12 def route_to @route_to end |
Instance Method Details
#check_errors(arr) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/new_post_result.rb', line 28 def check_errors(arr) if arr.empty? @success = true else arr.each { |e| errors.add(:base, e) if errors[:base].exclude?(e) } end end |
#check_errors_from(obj) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/new_post_result.rb', line 20 def check_errors_from(obj) if obj.errors.empty? @success = true else add_errors_from(obj) end end |
#failed? ⇒ Boolean
50 51 52 |
# File 'lib/new_post_result.rb', line 50 def failed? !@success end |
#queued_post ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/new_post_result.rb', line 36 def queued_post Discourse.deprecate( "NewPostManager#queued_post is deprecated. Please use #reviewable instead.", output_in_test: true, drop_from: "2.9.0", ) reviewable end |
#success? ⇒ Boolean
46 47 48 |
# File 'lib/new_post_result.rb', line 46 def success? @success end |