reform 1.2.4 → 1.2.5
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/CHANGES.md +4 -0
- data/README.md +15 -1
- data/database.sqlite3 +0 -0
- data/lib/reform/contract.rb +5 -1
- data/lib/reform/version.rb +1 -1
- data/test/contract_test.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b6f50b16163b7e3445a9efe6c8142f6dc9c87f5
|
4
|
+
data.tar.gz: fc8017f514448b2ea059cc39aa1dccd8a1106f94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6144492691a54df88a3f72680480db06021314c8dbe26de2cde0d65ac88ce1c9527f1546dd7ed9f23bc4bb4e134df177acacdde622a740fbb483c161a1108039
|
7
|
+
data.tar.gz: 9a648e2fcbf4d0708a8dc5966324be103f40233b8c17470585fd44e0e119117555d213045fd71077bfae2eec3353f444bd79522cd4902195ee5cd6298ad21973
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Add this line to your Gemfile:
|
|
19
19
|
gem 'reform'
|
20
20
|
```
|
21
21
|
|
22
|
-
##
|
22
|
+
## Nomenclature
|
23
23
|
|
24
24
|
Reform comes with two base classes.
|
25
25
|
|
@@ -935,6 +935,20 @@ class AlbumForm < Reform::Form
|
|
935
935
|
end
|
936
936
|
```
|
937
937
|
|
938
|
+
### Property Inflections
|
939
|
+
|
940
|
+
When rendering a form you might need to access the options you provided to `property`.
|
941
|
+
|
942
|
+
```ruby
|
943
|
+
property :title, type: String
|
944
|
+
```
|
945
|
+
|
946
|
+
You can do this using `#options_for`.
|
947
|
+
|
948
|
+
```ruby
|
949
|
+
form.options_for(:title) # => {:readable=>true, :coercion_type=>String}
|
950
|
+
```
|
951
|
+
|
938
952
|
|
939
953
|
## Support
|
940
954
|
|
data/database.sqlite3
CHANGED
Binary file
|
data/lib/reform/contract.rb
CHANGED
@@ -193,7 +193,11 @@ module Reform
|
|
193
193
|
|
194
194
|
module Readonly
|
195
195
|
def readonly?(name)
|
196
|
-
|
196
|
+
options_for(name)[:writeable] == false
|
197
|
+
end
|
198
|
+
|
199
|
+
def options_for(name)
|
200
|
+
self.class.representer_class.representable_attrs.get(name)
|
197
201
|
end
|
198
202
|
end
|
199
203
|
include Readonly
|
data/lib/reform/version.rb
CHANGED
data/test/contract_test.rb
CHANGED
@@ -94,4 +94,12 @@ class ContractTest < BaseTest
|
|
94
94
|
|
95
95
|
# test :superclass?
|
96
96
|
end
|
97
|
+
|
98
|
+
class SongContract < Reform::Contract
|
99
|
+
property :title, readable: true, type: String
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#options_for" do
|
103
|
+
it { SongContract.new(OpenStruct.new).options_for(:title)[:coercion_type].must_equal String }
|
104
|
+
end
|
97
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: representable
|