Class: Auditing::Modification

Inherits:
Object
  • Object
show all
Includes:
Mordor::Resource
Defined in:
lib/auditing/modification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.collection_nameObject



49
50
51
# File 'lib/auditing/modification.rb', line 49

def self.collection_name
  'audit_modifications'
end

.find_by_request(id) ⇒ Object



28
29
30
# File 'lib/auditing/modification.rb', line 28

def self.find_by_request(id)
  find_by_request_id(id)
end

.find_by_request_id(id) ⇒ Object



32
33
34
35
36
37
# File 'lib/auditing/modification.rb', line 32

def self.find_by_request_id(id)
  if id.is_a?(String)
    id = BSON::ObjectId.from_string(id)
  end
  Mordor::Collection.new(self, self.collection.find(:request_id => id))
end

Instance Method Details

#changes=(changes) ⇒ Object



45
46
47
# File 'lib/auditing/modification.rb', line 45

def changes=(changes)
  @changes = replace_params(changes)
end

#requestObject



20
21
22
# File 'lib/auditing/modification.rb', line 20

def request
  Auditing::Request.find_by_id(request_id)
end

#request=(request) ⇒ Object



24
25
26
# File 'lib/auditing/modification.rb', line 24

def request=(request)
  self.request_id = request._id
end

#request_id=(id) ⇒ Object



13
14
15
16
17
18
# File 'lib/auditing/modification.rb', line 13

def request_id=(id)
  if id.is_a?(String) && id != ""
    id = BSON::ObjectId.from_string(id)
  end
  @request_id = id
end

#to_hashObject



39
40
41
42
43
# File 'lib/auditing/modification.rb', line 39

def to_hash
  h = super
  h[:request_id] = request_id
  h
end