Class: Mongoid::AuditLog::EmbeddedChanges
- Inherits:
-
Object
- Object
- Mongoid::AuditLog::EmbeddedChanges
- Defined in:
- lib/mongoid/audit_log/embedded_changes.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(model) ⇒ EmbeddedChanges
constructor
A new instance of EmbeddedChanges.
- #relations ⇒ Object
Constructor Details
#initialize(model) ⇒ EmbeddedChanges
Returns a new instance of EmbeddedChanges.
6 7 8 |
# File 'lib/mongoid/audit_log/embedded_changes.rb', line 6 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/mongoid/audit_log/embedded_changes.rb', line 4 def model @model end |
Instance Method Details
#all ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mongoid/audit_log/embedded_changes.rb', line 18 def all @all ||= relations.inject({}) do |memo, t| name = t.first = model.send(name) changes = Mongoid::AuditLog::Changes.extract_from() if .present? && changes.present? memo[name] = changes end memo end end |
#relations ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mongoid/audit_log/embedded_changes.rb', line 10 def relations model.relations.inject({}) do |memo, t| name, relation = *t memo[name] = relation if relation. memo end end |