fuhen_record 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e91dd57d2d3feeaf0574b1ba92651de75df3b074f101396de7afbf66087973b9
4
+ data.tar.gz: 34c5b543eba4f9ba8f152f5b31f81d9fa310cda53b6596cb37553295444e698f
5
+ SHA512:
6
+ metadata.gz: 3f5cc9a4216e687022ecaca3cc9221a972457d1132a6659e56cf986478399ead767fd441a6b7963b09ef401fde653458d3e56a7b927a403d9f71a59137720aaf
7
+ data.tar.gz: 1e5edfd114fc1af60f832648a9af58ce7316515b6d4eccb836a486390a818d9ba87e86c703cab03f234ad7c978bf911e49b308d27bed84a33fd114af1453bda5
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright SaekiMototsune
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # FuhenRecord
2
+ FuhenRecord is a Rails extension that makes ActiveRecord models immutable.
3
+
4
+ There are already a bunch of gems on RubyGems that do similar things.
5
+ I just couldn’t find one that felt actively maintained, so I made this.
6
+
7
+ (That said, I can’t guarantee this gem will stay well-maintained forever.)
8
+
9
+ ## Installation
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem "fuhen_record"
14
+ ```
15
+
16
+ And then execute:
17
+ ```bash
18
+ $ bundle
19
+ ```
20
+
21
+ ## Usage
22
+ To make your model immutable, add `immutable_record` like this:
23
+
24
+ ```ruby
25
+ class AccessLog < ApplicationRecord
26
+ immutable_record
27
+ end
28
+ ```
29
+
30
+ ## Contributing
31
+ Contribute however you like.
32
+
33
+ AI-generated contribution guide, just in case:
34
+
35
+ 1. Fork the repository
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
40
+
41
+ ## License
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/setup"
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ module FuhenRecord
2
+ module ImmutableRecord
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ def immutable_record
7
+ alias_method :readonly?, :persisted? # accpect only persisted records at this time.
8
+ alias_method :delete, :raise_readonly_error
9
+ end
10
+ end
11
+
12
+ def raise_readonly_error
13
+ raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ module FuhenRecord
2
+ class Railtie < ::Rails::Railtie
3
+ initializer "fuhen_record.active_record" do
4
+ ActiveSupport.on_load(:active_record) do
5
+ include FuhenRecord::ImmutableRecord
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module FuhenRecord
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "fuhen_record/version"
2
+ require "fuhen_record/railtie"
3
+ require "fuhen_record/immutable_record"
4
+
5
+ module FuhenRecord
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :fuhen_record do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuhen_record
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - SaekiMototsune
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 8.1.2
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 8.1.2
26
+ description: FuhenRecord is a Rails extension that makes ActiveRecord models immutable.
27
+ email:
28
+ - saeki.mototsune@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - MIT-LICENSE
34
+ - README.md
35
+ - Rakefile
36
+ - lib/fuhen_record.rb
37
+ - lib/fuhen_record/immutable_record.rb
38
+ - lib/fuhen_record/railtie.rb
39
+ - lib/fuhen_record/version.rb
40
+ - lib/tasks/fuhen_record_tasks.rake
41
+ homepage: https://github.com/saeki-mototsune/fuhen_record
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ homepage_uri: https://github.com/saeki-mototsune/fuhen_record
46
+ source_code_uri: https://github.com/saeki-mototsune/fuhen_record
47
+ changelog_uri: https://github.com/saeki-mototsune/fuhen_record/CHANGELOG.md
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 4.0.6
63
+ specification_version: 4
64
+ summary: Immutable ActiveRecord extension for Rails
65
+ test_files: []