activemodel-form 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +1 -5
- data/CHANGELOG.md +4 -0
- data/lib/active_model/form.rb +4 -0
- data/lib/active_model/form/version.rb +1 -1
- data/spec/active_record_interface_spec.rb +17 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5cf91abe302d75a952dc4897b2058e24bec7ee6443de82a0564b4f0891fd8e95
|
4
|
+
data.tar.gz: eabc9b8439ee54ee6fd0e99869f9b4185e01f32a16bd00b167386b320d2f7d12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b980afdbf9e9799062657377c6155bcd1a29d861bc284ec49668bb113a75ae1f3078b1083399ce50b8c9bdd76b84c05a70c955a7615b0db105c01e05f4da9402
|
7
|
+
data.tar.gz: 06ecdc4e6853800b9e5fbdd32d423e3604e08f2092ec7bf58e650c8cae32a9eb961c5423a090caba43da1e788d2b08ff56335f6b4684bc18de540bff873549f8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/active_model/form.rb
CHANGED
@@ -40,6 +40,10 @@ module ActiveModel
|
|
40
40
|
self.class.attributes[name.to_s]
|
41
41
|
end
|
42
42
|
|
43
|
+
def has_attribute?(name)
|
44
|
+
self.class.attributes[name.to_s].present?
|
45
|
+
end
|
46
|
+
|
43
47
|
def assign_attributes(new_attributes)
|
44
48
|
return if new_attributes.blank?
|
45
49
|
new_attributes = self.clean_attributes(new_attributes)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveModel::Form do
|
4
|
+
it "implements the active_record interface" do
|
5
|
+
class Form < ActiveModel::Form
|
6
|
+
attribute :username, :string
|
7
|
+
end
|
8
|
+
|
9
|
+
form = Form.new(username: 'test')
|
10
|
+
|
11
|
+
form.column_for_attribute(:username).must_equal ActiveModel::Form::StringAttribute
|
12
|
+
form.column_for_attribute(:created_at).must_equal nil
|
13
|
+
|
14
|
+
form.has_attribute?(:username).must_equal true
|
15
|
+
form.has_attribute?(:created_at).must_equal false
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Schuerrer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/active_model/form/attributes.rb
|
158
158
|
- lib/active_model/form/version.rb
|
159
159
|
- lib/activemodel-form.rb
|
160
|
+
- spec/active_record_interface_spec.rb
|
160
161
|
- spec/boolean_attribute_form_spec.rb
|
161
162
|
- spec/date_time_form_spec.rb
|
162
163
|
- spec/date_time_string_spec.rb
|
@@ -184,11 +185,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
version: '0'
|
185
186
|
requirements: []
|
186
187
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.7.3
|
188
189
|
signing_key:
|
189
190
|
specification_version: 4
|
190
191
|
summary: ''
|
191
192
|
test_files:
|
193
|
+
- spec/active_record_interface_spec.rb
|
192
194
|
- spec/boolean_attribute_form_spec.rb
|
193
195
|
- spec/date_time_form_spec.rb
|
194
196
|
- spec/date_time_string_spec.rb
|