active_archive 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 708684462d2eb0f909f66ee848d41bc50e1e78cd
4
- data.tar.gz: 9efbe21473ce0ba4eca9e7000c7536eed1ce9e51
3
+ metadata.gz: 60185c6924bee924839cffc700ca82fea6244b3c
4
+ data.tar.gz: 3b533e035064b8d54f20cef9f8a8b1dadc81538a
5
5
  SHA512:
6
- metadata.gz: c5a9d9caf4b278cf45f3a542806c46b778fdb2e1da6e789560f38586dcea91fd2128b0f4cd5456f1bf0bd5b2a63aa783c4e1ce080cc5b6b3a4d95d14c60c0f00
7
- data.tar.gz: 2a9de28108e33fec99de7060f5327eb692be92b1d4ac1e8dfdfe9ed0543802cfe804f79dac8dc1c1b278cc9d26119462679fb1b3cf48004b6e34f72d277b2d6d
6
+ metadata.gz: 282ea0ada88bbb6d94e26100b9f2d1701fa8f532a0a396b8979648a3126dd4d2573c582f2c962f3cd46151bd2a899d69aec9164b08ef405856f994fd467fbe15
7
+ data.tar.gz: 77573041c37ac6dae54b8d12e3ccf9bbc3420112657e8feca96b0ec570366310ae680c84ad7751891c418f435f9efb1524a303e65b0446c76b2063275c997eb2
@@ -1,5 +1,5 @@
1
- require "active_archive/version"
2
- require "active_archive/configuration"
1
+ require 'active_archive/version'
2
+ require 'active_archive/configuration'
3
3
 
4
4
  module ActiveArchive
5
5
 
@@ -21,11 +21,11 @@ module ActiveArchive
21
21
 
22
22
  end
23
23
 
24
- require "active_archive/table_definition"
25
- require "active_archive/methods"
26
- require "active_archive/scopes"
27
- require "active_archive/base"
28
- require "generators/active_archive/install_generator"
24
+ require 'active_archive/table_definition'
25
+ require 'active_archive/methods'
26
+ require 'active_archive/scopes'
27
+ require 'active_archive/base'
28
+ require 'generators/active_archive/install_generator'
29
29
 
30
30
  ActiveRecord::Base.send(:include, ActiveArchive::Base)
31
31
 
@@ -71,7 +71,7 @@ module ActiveArchive
71
71
 
72
72
  def get_dependent_records
73
73
  dependent_records = {}
74
- self.class.reflections.each do |key, reflection|
74
+ self.class.reflections.lazy.each do |key, reflection|
75
75
  if reflection.options[:dependent] == :destroy
76
76
  next unless records = self.send(key)
77
77
  if records.respond_to?(:size)
@@ -88,7 +88,7 @@ module ActiveArchive
88
88
  end
89
89
 
90
90
  def permanently_delete_records(dependent_records)
91
- dependent_records.each do |klass, ids|
91
+ dependent_records.lazy.each do |klass, ids|
92
92
  ids.each do |id|
93
93
  record = begin
94
94
  klass.unscoped.find(id)
@@ -110,11 +110,12 @@ module ActiveArchive
110
110
 
111
111
  def unarchive_destroyed_dependent_records
112
112
  self.class.reflections
113
- .select { |name, reflection| (reflection.options[:dependent].to_s == "destroy") && reflection.klass.archivable? }
113
+ .lazy
114
+ .select { |name, reflection| (reflection.options[:dependent].to_s == 'destroy'.freeze) && reflection.klass.archivable? }
114
115
  .each do |name, reflection|
115
- cardinality = reflection.macro.to_s.gsub('has_', '')
116
+ cardinality = reflection.macro.to_s.gsub('has_'.freeze, ''.freeze)
116
117
 
117
- if cardinality == 'many'
118
+ if cardinality == 'many'.freeze
118
119
  records = archived_at.nil? ? send(name).unscoped : send(name).unscoped.where(
119
120
  [
120
121
  "#{reflection.quoted_table_name}.archived_at > ? AND #{reflection.quoted_table_name}.archived_at < ?",
@@ -122,13 +123,13 @@ module ActiveArchive
122
123
  archived_at + ActiveArchive.configuration.dependent_record_window
123
124
  ]
124
125
  )
125
- elsif cardinality == 'one' or cardinality == 'belongs_to'
126
+ elsif cardinality == 'one'.freeze or cardinality == 'belongs_to'.freeze
126
127
  self.class.unscoped do
127
128
  records = [] << send(name)
128
129
  end
129
130
  end
130
131
 
131
- [records].flatten.compact.each { |d| d.unarchive }
132
+ [records].flatten.compact.lazy.each { |d| d.unarchive }
132
133
  send(name, :reload)
133
134
  end
134
135
  end
@@ -141,18 +142,18 @@ module ActiveArchive
141
142
  begin
142
143
  should_ignore_validations?(force) ? record.save(validate: false) : record.save!
143
144
 
144
- if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) < ::Gem::Version.new('4.2.0')
145
+ if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) < ::Gem::Version.new('4.2.0'.freeze)
145
146
  @attributes = record.attributes
146
147
  @attributes_cache = record.attributes.except(record.class.serialized_attributes.keys)
147
148
 
148
149
  if defined?(::ActiveRecord::AttributeMethods::Serialization::Attribute)
149
150
  serialized_attribute_class = ::ActiveRecord::AttributeMethods::Serialization::Attribute
150
- self.class.serialized_attributes.each do |key, coder|
151
+ self.class.serialized_attributes.lazy.each do |key, coder|
151
152
  @attributes[key] = serialized_attribute_class.new(coder, @attributes[key], :unserialized) if @attributes.key?(key)
152
153
  end
153
154
  end
154
155
  else
155
- @attributes = record.instance_variable_get('@attributes')
156
+ @attributes = record.instance_variable_get('@attributes'.freeze)
156
157
  end
157
158
  rescue Exception => e
158
159
  record.destroy
@@ -2,7 +2,7 @@ module ActiveArchive
2
2
  module Methods
3
3
 
4
4
  def archivable?
5
- columns.detect { |c| c.name == "archived_at" }
5
+ columns.lazy.detect { |c| c.name == 'archived_at'.freeze }
6
6
  end
7
7
 
8
8
  def archive_all(conditions=nil)
@@ -10,7 +10,7 @@ module ActiveArchive
10
10
  end
11
11
 
12
12
  def unarchive_all(conditions=nil)
13
- (conditions ? where(conditions) : all).to_a.each { |r| r.unarchive }
13
+ (conditions ? where(conditions) : all).to_a.lazy.each { |r| r.unarchive }
14
14
  end
15
15
 
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveArchive
2
- VERSION = "2.2.2"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -1,11 +1,11 @@
1
- require "rails/generators"
1
+ require 'rails/generators'
2
2
 
3
3
  module ActiveArchive
4
4
  class InstallGenerator < Rails::Generators::Base
5
5
  source_root File.expand_path('../templates', __FILE__)
6
6
 
7
7
  def copy_initializer_file
8
- copy_file("install.rb", "config/initializers/active_archive.rb")
8
+ copy_file('install.rb'.freeze, 'config/initializers/active_archive.rb'.freeze)
9
9
  end
10
10
 
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails