form_core 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/db/migrate/{20170430190404_create_form_core_forms.rb → 20170430190404_create_forms.rb} +1 -1
- data/db/migrate/{20170430191336_create_form_core_fields.rb → 20170430191336_create_fields.rb} +1 -1
- data/lib/form_core/concerns/models/form.rb +16 -0
- data/lib/form_core/version.rb +1 -1
- data/lib/form_core/virtual_model.rb +12 -11
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88c1f8ae832ce81300e9a18e3da6e421b6acb4cd
|
4
|
+
data.tar.gz: a8f383d55d6ffb29b9622997d2a8ddf36de85cf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b46ed6033fd52676d9c0d9eecf4f72cc69b3627520e9993f112dfc4ae295f02c2da6b961f002d2373bb1d9d2eb0da82b6ec2b2354d10d7a95688bedc4312ab
|
7
|
+
data.tar.gz: 1044c2dff56c1e3df3909497ca794e509969a0364578744f3d5c9c7d14b705f2a771d2921967796446d403980d41605f6045a2e1ee54c8224fabcf775a9ed15b
|
data/README.md
CHANGED
@@ -12,12 +12,28 @@ module FormCore::Concerns
|
|
12
12
|
overrides: {})
|
13
13
|
model = FormCore.virtual_model_class.build model_name
|
14
14
|
|
15
|
+
append_to_virtual_model(model, fields_scope: fields_scope, overrides: overrides)
|
16
|
+
end
|
17
|
+
|
18
|
+
def append_to_virtual_model(model,
|
19
|
+
fields_scope: proc { |fields| fields },
|
20
|
+
overrides: {})
|
21
|
+
check_model_validity! model
|
22
|
+
|
15
23
|
fields_scope.call(fields).each do |f|
|
16
24
|
f.interpret_to model, overrides: overrides.fetch(f.name, {})
|
17
25
|
end
|
18
26
|
|
19
27
|
model
|
20
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def check_model_validity!(model)
|
33
|
+
unless model.is_a?(Class) && model < ::FormCore::VirtualModel
|
34
|
+
raise ArgumentError, "#{model} must be a #{::FormCore::VirtualModel}'s subclass"
|
35
|
+
end
|
36
|
+
end
|
21
37
|
end
|
22
38
|
end
|
23
39
|
end
|
data/lib/form_core/version.rb
CHANGED
@@ -7,15 +7,16 @@ module FormCore
|
|
7
7
|
def inspect
|
8
8
|
# We check defined?(@attributes) not to issue warnings if the object is
|
9
9
|
# allocated but not initialized.
|
10
|
-
inspection =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
inspection =
|
11
|
+
if defined?(@attributes) && @attributes
|
12
|
+
self.class.attribute_names.collect do |name|
|
13
|
+
if has_attribute?(name)
|
14
|
+
"#{name}: #{attribute_for_inspect(name)}"
|
15
|
+
end
|
16
|
+
end.compact.join(", ")
|
17
|
+
else
|
18
|
+
"not initialized"
|
19
|
+
end
|
19
20
|
|
20
21
|
"#<VirtualModel:#{self.class.name}:#{object_id} #{inspection}>"
|
21
22
|
end
|
@@ -23,7 +24,7 @@ module FormCore
|
|
23
24
|
public_class_method :define_method
|
24
25
|
class << self
|
25
26
|
def name
|
26
|
-
@
|
27
|
+
@_name ||= "Form"
|
27
28
|
end
|
28
29
|
|
29
30
|
def name=(value)
|
@@ -39,7 +40,7 @@ module FormCore
|
|
39
40
|
klass
|
40
41
|
end
|
41
42
|
|
42
|
-
# Returns a string like
|
43
|
+
# Returns a string like "Post(id:integer, title:string, body:text)"
|
43
44
|
def inspect
|
44
45
|
attr_list = attribute_types.map { |name, type| "#{name}: #{type.type}" } * ", "
|
45
46
|
"#<VirtualModel:#{name}:#{object_id} #{attr_list}>"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jasl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -53,8 +53,8 @@ files:
|
|
53
53
|
- app/models/form_core/application_record.rb
|
54
54
|
- app/models/form_core/field.rb
|
55
55
|
- app/models/form_core/form.rb
|
56
|
-
- db/migrate/
|
57
|
-
- db/migrate/
|
56
|
+
- db/migrate/20170430190404_create_forms.rb
|
57
|
+
- db/migrate/20170430191336_create_fields.rb
|
58
58
|
- lib/form_core.rb
|
59
59
|
- lib/form_core/concerns/models/field.rb
|
60
60
|
- lib/form_core/concerns/models/form.rb
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.6.
|
85
|
+
rubygems_version: 2.6.12
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: A Rails engine providing ability to generate dynamic form.
|