Class: Synchronisable::Context
Overview
Synchronization context.
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#before ⇒ Object
Returns the value of attribute before.
-
#deleted ⇒ Object
Returns the value of attribute deleted.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model, parent) ⇒ Context
constructor
A new instance of Context.
- #success? ⇒ Boolean
-
#summary_message ⇒ String
Summary synchronization info.
Constructor Details
#initialize(model, parent) ⇒ Context
Returns a new instance of Context.
7 8 9 10 11 |
# File 'lib/synchronisable/context.rb', line 7 def initialize(model, parent) @model, @parent = model, parent @errors = [] @before, @after, @deleted = 0, 0, 0 end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
4 5 6 |
# File 'lib/synchronisable/context.rb', line 4 def after @after end |
#before ⇒ Object
Returns the value of attribute before.
4 5 6 |
# File 'lib/synchronisable/context.rb', line 4 def before @before end |
#deleted ⇒ Object
Returns the value of attribute deleted.
4 5 6 |
# File 'lib/synchronisable/context.rb', line 4 def deleted @deleted end |
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/synchronisable/context.rb', line 4 def errors @errors end |
#model ⇒ Object
Returns the value of attribute model.
4 5 6 |
# File 'lib/synchronisable/context.rb', line 4 def model @model end |
Instance Method Details
#success? ⇒ Boolean
13 14 15 |
# File 'lib/synchronisable/context.rb', line 13 def success? errors.empty? end |
#summary_message ⇒ String
Returns summary synchronization info.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/synchronisable/context.rb', line 18 def msg = I18n.t('messages.result', :model => model, :parent => @parent.try(:model) || 'nil', :before => before, :after => after, :deleted => deleted, :errors => errors.count ) msg << I18n.t('messages.errors', errors: errors.join('. ')) if errors.any? msg end |