status_assignable 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +1 -1
- data/lib/status_assignable/active_record.rb +14 -0
- data/lib/status_assignable/railtie.rb +16 -0
- data/lib/status_assignable/version.rb +1 -1
- data/lib/status_assignable.rb +4 -1
- data/status_assignable.gemspec +2 -1
- metadata +3 -5
- data/.rspec +0 -3
- data/.rubocop.yml +0 -6
- data/lib/generators/status_assignable_patch_generator.rb +0 -10
- data/lib/generators/templates/monkey_patch.rb.erb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b20deebb9e80d8b065d513d7f63bf13419edf9ed574b96fc700c5724701c29df
|
4
|
+
data.tar.gz: 39177448f3790807ffc9e19750b081cdd01b77f5146ac3c682081192043450bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6383055f4d8504796034adb5e921ed3a0e9e3a7d0157eb1de642d52cd5315205388c9ceb0a1c7c6dd8de2a60deb96a412c2db30b38cf544a86b4cea8ef72948
|
7
|
+
data.tar.gz: 937d559db282dea965616474ec2f3325ccd18040e04e54d7bb79f29df475115fa573a9fa10cebdb16ee4575c312fb50916b89ddd7d0c9330481502d2ddce63a7
|
data/README.md
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StatusAssignable
|
4
|
+
# Integration with ActiveRecord so that the model can simply call has_assignable_status.
|
5
|
+
module ActiveRecord
|
6
|
+
def has_assignable_status(custom_statuses = nil) # rubocop:disable Naming/PredicateName
|
7
|
+
if custom_statuses.nil?
|
8
|
+
include StatusAssignable
|
9
|
+
else
|
10
|
+
include StatusAssignable[custom_statuses]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'association'
|
4
|
+
require_relative 'active_record'
|
5
|
+
|
6
|
+
module StatusAssignable
|
7
|
+
# Rails integration for the Status Assignable gem.
|
8
|
+
class Railtie < Rails::Railtie
|
9
|
+
initializer 'status_assignable.active_record' do |app|
|
10
|
+
app.reloader.to_prepare do
|
11
|
+
::ActiveRecord::Associations::Builder::Association.singleton_class.prepend Association
|
12
|
+
::ActiveRecord::Base.singleton_class.prepend ActiveRecord
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/status_assignable.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'status_assignable/version'
|
4
|
-
|
4
|
+
|
5
|
+
raise LoadError, 'The project is not a Rails project!' unless defined(Rails)
|
5
6
|
|
6
7
|
# Allows for soft deletion of records.
|
7
8
|
# Include this module in your model to enable soft deletion.
|
@@ -103,3 +104,5 @@ module StatusAssignable
|
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
107
|
+
|
108
|
+
require_relative 'status_assignable/railtie'
|
data/status_assignable.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.files = Dir.chdir(__dir__) do
|
19
19
|
`git ls-files -z`.split("\x0").reject do |f|
|
20
20
|
(File.expand_path(f) == __FILE__) ||
|
21
|
-
f.start_with?(*%w[bin/
|
21
|
+
f.start_with?(*%w[bin/ spec/ .git .github Gemfile]) ||
|
22
|
+
f.end_with?(*%w[.gem .yml .rspec .gitignore])
|
22
23
|
end
|
23
24
|
end
|
24
25
|
spec.bindir = 'exe'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: status_assignable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tien
|
@@ -31,16 +31,14 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- ".rspec"
|
35
|
-
- ".rubocop.yml"
|
36
34
|
- CODE_OF_CONDUCT.md
|
37
35
|
- LICENSE.txt
|
38
36
|
- README.md
|
39
37
|
- Rakefile
|
40
|
-
- lib/generators/status_assignable_patch_generator.rb
|
41
|
-
- lib/generators/templates/monkey_patch.rb.erb
|
42
38
|
- lib/status_assignable.rb
|
39
|
+
- lib/status_assignable/active_record.rb
|
43
40
|
- lib/status_assignable/association.rb
|
41
|
+
- lib/status_assignable/railtie.rb
|
44
42
|
- lib/status_assignable/version.rb
|
45
43
|
- status_assignable.gemspec
|
46
44
|
homepage: https://github.com/tieeeeen1994/rails-status-assignable
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Generates a patch for Rails so that status assignable models can have their associations archived when soft deleted.
|
4
|
-
class StatusAssignablePatchGenerator < Rails::Generators::Base
|
5
|
-
source_root File.expand_path('templates', __dir__)
|
6
|
-
|
7
|
-
def create_patch_file
|
8
|
-
template 'monkey_patch.rb.erb', File.join('config/initializers/status_assignable.rb')
|
9
|
-
end
|
10
|
-
end
|