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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 619499be038a8c119a14b9b66a7bf0b922b018c14a4258ccff64c94ca255407d
4
- data.tar.gz: 9e34b56aff3b351b09ca01f6d220d6d38cb5af097c7394f09f63db4aced48b2c
3
+ metadata.gz: b20deebb9e80d8b065d513d7f63bf13419edf9ed574b96fc700c5724701c29df
4
+ data.tar.gz: 39177448f3790807ffc9e19750b081cdd01b77f5146ac3c682081192043450bf
5
5
  SHA512:
6
- metadata.gz: afa83054aab31159694681db991ad7470083bc07ec3869abfb7b1c2f958988f1c069622da27633d98dce610cd3f6de2da52e197db1d8125605754b2f0d800f18
7
- data.tar.gz: 84b0626e4ebde55f1a6828c935e1b68f07ac1e3c76ca1bd15b82806cd22b2ee0b1df3deba52009b27b7085027d5c786465df02456c8d0e1cda8811ef7f4a25bf
6
+ metadata.gz: d6383055f4d8504796034adb5e921ed3a0e9e3a7d0157eb1de642d52cd5315205388c9ceb0a1c7c6dd8de2a60deb96a412c2db30b38cf544a86b4cea8ef72948
7
+ data.tar.gz: 937d559db282dea965616474ec2f3325ccd18040e04e54d7bb79f29df475115fa573a9fa10cebdb16ee4575c312fb50916b89ddd7d0c9330481502d2ddce63a7
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add this line to your application's Gemfile:
6
6
 
7
7
  ```ruby
8
- gem 'status_assignable', git: 'https://github.com/tieeeeen1994/rails-status-assignable'
8
+ gem 'status_assignable', '~> 0.1'
9
9
  ```
10
10
 
11
11
  After that, run the following command:
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StatusAssignable
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'status_assignable/version'
4
- require_relative 'status_assignable/association'
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'
@@ -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/ test/ spec/ features/ .git .github appveyor Gemfile])
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.0
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
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,6 +0,0 @@
1
- require:
2
- - rubocop-rake
3
-
4
- AllCops:
5
- TargetRubyVersion: 3.0
6
- NewCops: enable
@@ -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
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.reloader.to_prepare do
4
- ActiveRecord::Associations::Builder::Association.singleton_class.prepend StatusAssignable::Association
5
- end