Class: LogBook::Recorder::RecordingChanges

Inherits:
Object
  • Object
show all
Defined in:
lib/log_book/recorder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recorder) ⇒ RecordingChanges



122
123
124
125
126
127
# File 'lib/log_book/recorder.rb', line 122

def initialize(recorder)
  @subject = recorder
  @recording_key = subject.recording_key
  @record_changes = {}
  @meta = {}
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



115
116
117
# File 'lib/log_book/recorder.rb', line 115

def action
  @action
end

#authorObject (readonly)

Returns the value of attribute author.



116
117
118
# File 'lib/log_book/recorder.rb', line 116

def author
  @author
end

#metaObject

Returns the value of attribute meta.



118
119
120
# File 'lib/log_book/recorder.rb', line 118

def meta
  @meta
end

#record_changesObject

Returns the value of attribute record_changes.



117
118
119
# File 'lib/log_book/recorder.rb', line 117

def record_changes
  @record_changes
end

#recording_keyObject

Returns the value of attribute recording_key.



120
121
122
# File 'lib/log_book/recorder.rb', line 120

def recording_key
  @recording_key
end

#request_uuidObject (readonly)

Returns the value of attribute request_uuid.



119
120
121
# File 'lib/log_book/recorder.rb', line 119

def request_uuid
  @request_uuid
end

#subjectObject (readonly)

Returns the value of attribute subject.



114
115
116
# File 'lib/log_book/recorder.rb', line 114

def subject
  @subject
end

Instance Method Details

#changes?Boolean



137
138
139
# File 'lib/log_book/recorder.rb', line 137

def changes?
  meta.present? || record_changes.present?
end

#childrenObject



153
154
155
# File 'lib/log_book/recorder.rb', line 153

def children
  self.class.new(subject.send(subject.recording_options[:parent_of])) if subject.recording_options[:parent_of]
end

#parentObject



149
150
151
# File 'lib/log_book/recorder.rb', line 149

def parent
  self.class.new(subject.send(subject.recording_options[:parent])) if subject.recording_options[:parent]
end

#subject_idObject



145
146
147
# File 'lib/log_book/recorder.rb', line 145

def subject_id
  subject.id
end

#subject_keyObject



141
142
143
# File 'lib/log_book/recorder.rb', line 141

def subject_key
  subject.class.table_name
end

#to_hObject



157
158
159
160
161
162
163
# File 'lib/log_book/recorder.rb', line 157

def to_h
  {
    subject: subject,
    record_changes: record_changes,
    meta: meta
  }
end