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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9de1e1d5688d37d56c180a7b0c622a5319bd7347
4
- data.tar.gz: b68d927a7b7a2dc8beb287ce8692c4527866a731
3
+ metadata.gz: 4b6f50b16163b7e3445a9efe6c8142f6dc9c87f5
4
+ data.tar.gz: fc8017f514448b2ea059cc39aa1dccd8a1106f94
5
5
  SHA512:
6
- metadata.gz: 56c84d82a9e5981796d199a045d6e014e7f3dc1d69051e997b07c5b213c905a7f92c21d20b618907212f0a3544711b142f3fbd2d790bcc498ecfcaa5d290244c
7
- data.tar.gz: cce2349a4ff6c075a23bb28d9f536997f3f49c869b4f08469cedb2978e9d0784b858b0c0649b4ab770e8d12d340224c2472860668c05fd2eba97ca23e459ef13
6
+ metadata.gz: 6144492691a54df88a3f72680480db06021314c8dbe26de2cde0d65ac88ce1c9527f1546dd7ed9f23bc4bb4e134df177acacdde622a740fbb483c161a1108039
7
+ data.tar.gz: 9a648e2fcbf4d0708a8dc5966324be103f40233b8c17470585fd44e0e119117555d213045fd71077bfae2eec3353f444bd79522cd4902195ee5cd6298ad21973
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.2.5
2
+
3
+ * Added `Form#options_for` to have access to all property options.
4
+
1
5
  ## 1.2.4
2
6
 
3
7
  * Added `Form#readonly?` to find out whether a field is set to writeable. This is helpful for simple_form to display a disabled input field.
data/README.md CHANGED
@@ -19,7 +19,7 @@ Add this line to your Gemfile:
19
19
  gem 'reform'
20
20
  ```
21
21
 
22
- ## Nomenclatura
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
@@ -193,7 +193,11 @@ module Reform
193
193
 
194
194
  module Readonly
195
195
  def readonly?(name)
196
- self.class.representer_class.representable_attrs.get(name)[:writeable] == false
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
@@ -1,3 +1,3 @@
1
1
  module Reform
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  end
@@ -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
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: 2014-12-14 00:00:00.000000000 Z
12
+ date: 2015-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: representable