mongoid-archivable 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddee3e043b9d4b417645ca3bc5ee3afc4372b4f2
4
- data.tar.gz: 82addf9eb775e8218bdb7ef90271de14ebd6e3c7
3
+ metadata.gz: 9957577e624c1560404e6435b9713fa24ea54048
4
+ data.tar.gz: 2a85513a462e58eaaf81aac60b5074f363914d9b
5
5
  SHA512:
6
- metadata.gz: 2b0dec185d816f6c7e344cb8d833e782037842da01d7fdcdd4d90054d9c0497d9fe0b97661e94a00bbb9a8382c454193abb9aab72114f3afd02e6b0a4a4daecf
7
- data.tar.gz: 577e54c3a9cab48f1bbfa0e95dae6ddcce202ebefbd3dea4d4577537ca87e0906a24830f90faa8139885bb0ac406a0e6be3cf2c91d1a376fc009fb9a57a37ea7
6
+ metadata.gz: accc81a71d53bf7e5443ae99a3809593c5f3de4c448f8d800c49d1e7c2b709f146b109039f414b6d5799dcbabbe14bbfb0fd5fb5ed453827586f7f0ad987514e
7
+ data.tar.gz: 595a05d2b0e70e6934b0163a61b41f147f152facf670acc781e60f7140d61965dd91a497d3edf8220cfb6d6c34e6c9dbb62465a700f8ca4332466d6821950712
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Joost Baaij
3
+ Copyright (c) 2015-2016 Joost Baaij
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Archivable
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -2,7 +2,6 @@ require 'active_support/concern'
2
2
 
3
3
  module Mongoid
4
4
  module Archivable
5
-
6
5
  extend ActiveSupport::Concern
7
6
 
8
7
  module Restoration
@@ -13,8 +12,9 @@ module Mongoid
13
12
  end
14
13
 
15
14
  def original_document
16
- self.original_class_name.constantize.new(attributes.except("_id", "original_id", "original_type", "archived_at")) do |doc|
17
- doc.id = self.original_id
15
+ excluded_attributes = %i(_id original_id original_type archived_at)
16
+ original_class_name.constantize.new(attributes.except(*excluded_attributes)) do |doc|
17
+ doc.id = original_id
18
18
  end
19
19
  end
20
20
 
@@ -22,8 +22,8 @@ module Mongoid
22
22
  # since previous versions of this gem did not use this field, fall back
23
23
  # to previous method -- removing the '::Archive' from archive class name
24
24
  def original_class_name
25
- if self.respond_to?(:original_type) && self.original_type.present? # gem version >= 1.3.0, stored as a field.
26
- self.original_type
25
+ if respond_to?(:original_type) && original_type.present? # gem version >= 1.3.0, stored as a field.
26
+ original_type
27
27
  else
28
28
  self.class.to_s.gsub(/::Archive\z/, '') # gem version < 1.3.0, turns "User::Archive" into "User".
29
29
  end
@@ -31,11 +31,12 @@ module Mongoid
31
31
  end
32
32
 
33
33
  included do
34
- self.const_set("Archive", Class.new)
35
- self.const_get("Archive").class_eval do
34
+ const_set('Archive', Class.new)
35
+ const_get('Archive').class_eval do
36
36
  include Mongoid::Document
37
37
  include Mongoid::Attributes::Dynamic
38
38
  include Mongoid::Archivable::Restoration
39
+
39
40
  field :archived_at, type: Time
40
41
  field :original_id, type: String
41
42
  field :original_type, type: String
@@ -47,12 +48,11 @@ module Mongoid
47
48
  private
48
49
 
49
50
  def archive
50
- self.class.const_get("Archive").create(attributes.except("_id", "_type")) do |doc|
51
- doc.original_id = self.id
51
+ self.class.const_get('Archive').create(attributes.except('_id', '_type')) do |doc|
52
+ doc.original_id = id
52
53
  doc.original_type = self.class.to_s
53
54
  doc.archived_at = Time.now.utc
54
55
  end
55
56
  end
56
-
57
57
  end
58
58
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "mongoid"
22
+ spec.add_dependency "mongoid", "~> 5.0"
23
23
  spec.add_dependency "activesupport", ">= 4.0.0"
24
24
 
25
25
  spec.add_development_dependency "bundler"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-archivable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joost Baaij
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2016-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement