activerecord-be_readonly 0.1.0 → 0.2.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: 0f07236a1f88846395e09422c09c4076fe32d483
4
- data.tar.gz: 4d253bf6885c7c79163de783ea4ec6ac2f195fe7
3
+ metadata.gz: ed4c428fad39b95f257a878fc37f82e6a52b30e7
4
+ data.tar.gz: 0feda1824be051213a474d3fe73991337c39d49c
5
5
  SHA512:
6
- metadata.gz: bb3ab5c8382a45aa5980b287df2fed99ebcffeaa89e3dca32207a1323989ed0799ea0fc0081277773c1e37b199a4e234bd227c047bd1612c97cdd53556512f64
7
- data.tar.gz: 3cc9fac3386e8ea6c68b9f8db808234e00c437575886bd4bd90b428f165ab5180db24f86228302c130aba6e8d3e5ad504c0bc702a61c4ddf1881adf02b648922
6
+ metadata.gz: 93854ae9a962220cb2bd9a9ba4286b92f91eddfaccf9e4857e4944eb52d6bbab3f70216da65e56fce896713533db135bd1ee8ed7aa46f8c2d7e79eb28467640a
7
+ data.tar.gz: ec55651678ae50f371838aab3b1c9b7fbe99e1844c621419601e79c4970c7a9f8486c0b756ae54cc1a401c0eff8620f7d70b8c1ff73ee7b362c29d2595c9a061
data/README.md CHANGED
@@ -41,10 +41,15 @@ Or if you are off-rails, but use ActiveRecord, just do this in the model class:
41
41
 
42
42
  ### Configuration
43
43
 
44
- Useful if you'd like to turn off read-only only for tests, etc.
44
+ You can create an initializer (`/config/initializers/activerecord-be_readonly.rb`) with the following options:
45
45
 
46
- # application-wide setting. true by default.
47
- BeReadonly.enabled = false
46
+ To turn off read-only application-wide, set the enabled setting to false (useful if you'd like to turn off read-only only for tests, etc.)
47
+
48
+ BeReadonly.enabled = false # Default: true
49
+
50
+ To disable read-only for record creation application-wide, set the create_allowed setting to true
51
+
52
+ BeReadonly.create_allowed = true # Default: false
48
53
 
49
54
  ### Contributors
50
55
 
@@ -52,6 +57,7 @@ Thanks to:
52
57
  * [vkhater](https://github.com/vkhater)
53
58
  * [Gabriel Naiman](https://github.com/gabynaiman)
54
59
  * [Gary Weaver](https://github.com/garysweaver)
60
+ * [Kevin Zych](https://github.com/kayzee)
55
61
 
56
62
  ### License
57
63
 
@@ -1,7 +1,9 @@
1
1
  module BeReadonly
2
2
  class << self
3
3
  attr_accessor :enabled
4
+ attr_accessor :create_allowed
4
5
  end
5
6
  end
6
7
 
7
8
  BeReadonly.enabled = true
9
+ BeReadonly.create_allowed = false
@@ -32,7 +32,7 @@ module BeReadonly
32
32
 
33
33
  module BeReadonlyInstanceMethods
34
34
  def readonly?
35
- return true if BeReadonly.enabled
35
+ return true if BeReadonly.enabled && !(BeReadonly.create_allowed && new_record?)
36
36
  super
37
37
  end
38
38
 
@@ -1,3 +1,3 @@
1
1
  module BeReadonly
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-be_readonly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary S. Weaver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-17 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
27
33
  description: Makes read-only models easier to implement in ActiveRecord 3.x/4.x.
28
34
  email:
29
35
  - garysweaver@gmail.com