yaks 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +158 -56
- data/Rakefile +1 -3
- data/ataru_setup.rb +72 -0
- data/find_missing_tests.rb +34 -0
- data/lib/yaks.rb +8 -10
- data/lib/yaks/breaking_changes.rb +4 -6
- data/lib/yaks/builder.rb +1 -1
- data/lib/yaks/changelog.rb +1 -1
- data/lib/yaks/collection_mapper.rb +8 -5
- data/lib/yaks/collection_resource.rb +0 -1
- data/lib/yaks/config.rb +17 -7
- data/lib/yaks/configurable.rb +20 -14
- data/lib/yaks/default_policy.rb +82 -33
- data/lib/yaks/format.rb +7 -3
- data/lib/yaks/format/collection_json.rb +4 -4
- data/lib/yaks/format/hal.rb +1 -2
- data/lib/yaks/format/halo.rb +2 -4
- data/lib/yaks/format/json_api.rb +46 -27
- data/lib/yaks/html5_forms.rb +0 -2
- data/lib/yaks/mapper.rb +5 -5
- data/lib/yaks/mapper/association.rb +7 -7
- data/lib/yaks/mapper/association_mapper.rb +2 -0
- data/lib/yaks/mapper/attribute.rb +10 -4
- data/lib/yaks/mapper/config.rb +2 -2
- data/lib/yaks/mapper/form.rb +4 -10
- data/lib/yaks/mapper/form/config.rb +16 -17
- data/lib/yaks/mapper/form/dynamic_field.rb +1 -1
- data/lib/yaks/mapper/form/field.rb +16 -7
- data/lib/yaks/mapper/form/field/option.rb +5 -4
- data/lib/yaks/mapper/form/fieldset.rb +1 -1
- data/lib/yaks/mapper/form/legend.rb +18 -0
- data/lib/yaks/mapper/has_many.rb +1 -0
- data/lib/yaks/mapper/link.rb +7 -4
- data/lib/yaks/null_resource.rb +4 -5
- data/lib/yaks/pipeline.rb +2 -2
- data/lib/yaks/primitivize.rb +3 -2
- data/lib/yaks/reader/hal.rb +12 -13
- data/lib/yaks/reader/json_api.rb +50 -33
- data/lib/yaks/resource.rb +6 -7
- data/lib/yaks/resource/form.rb +2 -12
- data/lib/yaks/resource/form/field.rb +4 -3
- data/lib/yaks/resource/form/field/option.rb +1 -1
- data/lib/yaks/resource/form/fieldset.rb +1 -1
- data/lib/yaks/resource/form/legend.rb +18 -0
- data/lib/yaks/resource/has_fields.rb +13 -7
- data/lib/yaks/resource/link.rb +1 -1
- data/lib/yaks/runner.rb +5 -2
- data/lib/yaks/serializer.rb +2 -3
- data/lib/yaks/util.rb +7 -8
- data/lib/yaks/version.rb +1 -1
- data/spec/acceptance/acceptance_spec.rb +53 -38
- data/spec/acceptance/json_shared_examples.rb +45 -12
- data/spec/acceptance/models.rb +1 -1
- data/spec/integration/dynamic_form_fields_spec.rb +0 -1
- data/spec/integration/fieldset_spec.rb +18 -20
- data/spec/integration/map_to_resource_spec.rb +6 -6
- data/spec/json/{confucius.collection.json → confucius.collection_json.json} +0 -0
- data/spec/json/confucius.json_api.json +43 -27
- data/spec/json/list_of_quotes.collection_json.json +43 -0
- data/spec/json/list_of_quotes.hal.json +18 -0
- data/spec/json/list_of_quotes.json_api.json +25 -0
- data/spec/json/youtypeitwepostit.collection_json.json +45 -0
- data/spec/spec_helper.rb +4 -3
- data/spec/support/classes_for_policy_testing.rb +38 -14
- data/spec/support/deep_eql.rb +21 -18
- data/spec/support/pet_mapper.rb +2 -0
- data/spec/support/shared_contexts.rb +9 -9
- data/spec/unit/yaks/builder_spec.rb +41 -18
- data/spec/unit/yaks/collection_mapper_spec.rb +22 -19
- data/spec/unit/yaks/collection_resource_spec.rb +16 -8
- data/spec/unit/yaks/config_spec.rb +215 -19
- data/spec/unit/yaks/configurable_spec.rb +66 -7
- data/spec/unit/yaks/default_policy/derive_mapper_from_collection_spec.rb +47 -0
- data/spec/unit/yaks/default_policy/derive_mapper_from_item_spec.rb +114 -0
- data/spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb +29 -71
- data/spec/unit/yaks/default_policy_spec.rb +4 -5
- data/spec/unit/yaks/format/collection_json_spec.rb +35 -36
- data/spec/unit/yaks/format/hal_spec.rb +3 -3
- data/spec/unit/yaks/format/json_api_spec.rb +109 -68
- data/spec/unit/yaks/format_spec.rb +34 -0
- data/spec/unit/yaks/fp/callable_spec.rb +5 -3
- data/spec/unit/yaks/mapper/association_mapper_spec.rb +22 -4
- data/spec/unit/yaks/mapper/association_spec.rb +23 -11
- data/spec/unit/yaks/mapper/attribute_spec.rb +46 -7
- data/spec/unit/yaks/mapper/config_spec.rb +2 -3
- data/spec/unit/yaks/mapper/form/config_spec.rb +95 -0
- data/spec/unit/yaks/mapper/form/dynamic_field_spec.rb +30 -0
- data/spec/unit/yaks/mapper/form/field/option_spec.rb +48 -4
- data/spec/unit/yaks/mapper/form/field_spec.rb +43 -2
- data/spec/unit/yaks/mapper/form/fieldset_spec.rb +67 -8
- data/spec/unit/yaks/mapper/form/legend_spec.rb +52 -0
- data/spec/unit/yaks/mapper/form_spec.rb +84 -23
- data/spec/unit/yaks/mapper/has_many_spec.rb +39 -36
- data/spec/unit/yaks/mapper/has_one_spec.rb +28 -20
- data/spec/unit/yaks/mapper/link_spec.rb +68 -16
- data/spec/unit/yaks/mapper_spec.rb +118 -30
- data/spec/unit/yaks/null_resource_spec.rb +83 -52
- data/spec/unit/yaks/pipeline_spec.rb +101 -74
- data/spec/unit/yaks/primitivize_spec.rb +25 -6
- data/spec/unit/yaks/resource/form/field_spec.rb +5 -5
- data/spec/unit/yaks/resource/form/fieldset_spec.rb +7 -0
- data/spec/unit/yaks/resource/form/legend_spec.rb +8 -0
- data/spec/unit/yaks/resource/form_spec.rb +17 -37
- data/spec/unit/yaks/resource/has_fields_spec.rb +44 -3
- data/spec/unit/yaks/resource/link_spec.rb +11 -6
- data/spec/unit/yaks/resource_spec.rb +87 -98
- data/spec/unit/yaks/runner_spec.rb +112 -28
- data/spec/unit/yaks/serializer_spec.rb +1 -1
- data/spec/unit/yaks/util_spec.rb +30 -10
- data/spec/yaml/list_of_quotes.yaml +13 -0
- data/yaks.gemspec +21 -13
- metadata +129 -41
- data/lib/yaks/attributes.rb +0 -86
- data/lib/yaks/fp.rb +0 -26
- data/lib/yaks/identifier/link_relation.rb +0 -17
- data/resources/iana-link-relations.csv +0 -152
- data/spec/json/youtypeitwepostit.collection.json +0 -45
- data/spec/unit/yaks/attributes_spec.rb +0 -178
- data/spec/unit/yaks/fp_spec.rb +0 -29
@@ -2,16 +2,21 @@ module Yaks
|
|
2
2
|
class Mapper
|
3
3
|
class Form
|
4
4
|
class Field
|
5
|
-
include
|
5
|
+
include Attribs.new(
|
6
6
|
:name,
|
7
7
|
label: nil,
|
8
8
|
options: [].freeze,
|
9
9
|
if: nil
|
10
10
|
).add(HTML5Forms::FIELD_OPTIONS)
|
11
11
|
|
12
|
-
Builder = Builder.new(self) do
|
12
|
+
Builder = Yaks::Builder.new(self) do
|
13
13
|
def_set :name, :label
|
14
14
|
def_add :option, create: Option, append_to: :options
|
15
|
+
|
16
|
+
def condition(blk1 = nil, &blk2)
|
17
|
+
@config = @config.with(if: blk1 || blk2)
|
18
|
+
end
|
19
|
+
|
15
20
|
HTML5Forms::FIELD_OPTIONS.each do |option, _|
|
16
21
|
def_set option
|
17
22
|
end
|
@@ -28,9 +33,9 @@ module Yaks
|
|
28
33
|
# Convert to a Resource::Form::Field, expanding any dynamic
|
29
34
|
# values
|
30
35
|
def to_resource_fields(mapper)
|
31
|
-
return []
|
36
|
+
return [] unless self.if.nil? || mapper.expand_value(self.if)
|
32
37
|
[ Resource::Form::Field.new(
|
33
|
-
|
38
|
+
resource_attributes.each_with_object({}) do |attr, attrs|
|
34
39
|
attrs[attr] = mapper.expand_value(public_send(attr))
|
35
40
|
end.merge(options: resource_options(mapper))) ]
|
36
41
|
end
|
@@ -38,15 +43,19 @@ module Yaks
|
|
38
43
|
def resource_options(mapper)
|
39
44
|
# make sure all empty options arrays are the same instance,
|
40
45
|
# makes for prettier #pp
|
41
|
-
options.empty?
|
46
|
+
if options.empty?
|
47
|
+
options
|
48
|
+
else
|
49
|
+
options.map {|opt| opt.to_resource_field_option(mapper) }.compact
|
50
|
+
end
|
42
51
|
end
|
43
52
|
|
44
53
|
# All attributes that can be converted 1-to-1 to
|
45
54
|
# Resource::Form::Field
|
46
55
|
def resource_attributes
|
47
|
-
self.class.attributes.names - [:options]
|
56
|
+
self.class.attributes.names - [:options, :if]
|
48
57
|
end
|
49
|
-
end #Field
|
58
|
+
end # Field
|
50
59
|
end # Form
|
51
60
|
end # Mapper
|
52
61
|
end # Yaks
|
@@ -4,19 +4,20 @@ module Yaks
|
|
4
4
|
class Field
|
5
5
|
# <option>, as used in a <select>
|
6
6
|
class Option
|
7
|
-
include
|
7
|
+
include Attribs.new(:value, :label, selected: false, disabled: false, if: nil)
|
8
8
|
|
9
|
-
def self.create(value, opts
|
9
|
+
def self.create(value, opts)
|
10
10
|
new(opts.merge(value: value))
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_resource_field_option(mapper)
|
14
|
-
return
|
14
|
+
return unless self.if.nil? || mapper.expand_value(self.if)
|
15
|
+
|
15
16
|
Resource::Form::Field::Option.new(
|
16
17
|
value: mapper.expand_value(value),
|
17
18
|
label: mapper.expand_value(label),
|
18
19
|
selected: mapper.expand_value(selected),
|
19
|
-
disabled: mapper.expand_value(disabled)
|
20
|
+
disabled: mapper.expand_value(disabled)
|
20
21
|
)
|
21
22
|
end
|
22
23
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Yaks
|
2
|
+
class Mapper
|
3
|
+
class Form
|
4
|
+
class Legend
|
5
|
+
include Attribs.new(:type, :label, if: nil)
|
6
|
+
|
7
|
+
def self.create(label, opts = {})
|
8
|
+
new(opts.merge(type: :legend, label: label))
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_resource_fields(mapper)
|
12
|
+
return [] unless self.if.nil? || mapper.expand_value(self.if)
|
13
|
+
[ Resource::Form::Legend.new(label: mapper.expand_value(label)) ]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/yaks/mapper/has_many.rb
CHANGED
@@ -12,6 +12,7 @@ module Yaks
|
|
12
12
|
collection_mapper(collection, policy).new(context).call(collection)
|
13
13
|
end
|
14
14
|
|
15
|
+
undef collection_mapper
|
15
16
|
def collection_mapper(collection = nil, policy = nil)
|
16
17
|
return @collection_mapper unless @collection_mapper.equal? Undefined
|
17
18
|
policy.derive_mapper_from_object(collection) if policy && collection
|
data/lib/yaks/mapper/link.rb
CHANGED
@@ -25,15 +25,17 @@ module Yaks
|
|
25
25
|
# it will receive the mapper instance as argument. Otherwise it is evaluated in the mapper context
|
26
26
|
class Link
|
27
27
|
extend Forwardable, Util
|
28
|
-
include
|
28
|
+
include Attribs.new(:rel, :template, options: {}), Util
|
29
29
|
|
30
30
|
def self.create(*args)
|
31
31
|
args, options = extract_options(args)
|
32
|
-
new(rel: args
|
32
|
+
new(rel: args.first, template: args.last, options: options)
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_to_resource(resource, mapper, _context)
|
36
|
-
|
36
|
+
if options[:remove]
|
37
|
+
return resource.with(links: resource.links.reject {|link| link.rel?(rel)})
|
38
|
+
end
|
37
39
|
|
38
40
|
resource_link = map_to_resource_link(mapper)
|
39
41
|
return resource unless resource_link
|
@@ -67,13 +69,14 @@ module Yaks
|
|
67
69
|
)
|
68
70
|
end
|
69
71
|
|
72
|
+
private
|
73
|
+
|
70
74
|
def resource_link_options(mapper)
|
71
75
|
options = options()
|
72
76
|
options = options.merge(title: Resolve(options[:title], mapper)) if options.key?(:title)
|
73
77
|
options = options.merge(templated: true) if templated?
|
74
78
|
options.reject{|key| [:expand, :replace, :if].include? key }
|
75
79
|
end
|
76
|
-
|
77
80
|
end
|
78
81
|
end
|
79
82
|
end
|
data/lib/yaks/null_resource.rb
CHANGED
@@ -4,10 +4,10 @@ module Yaks
|
|
4
4
|
Equalizer.new(:rels, :collection)
|
5
5
|
|
6
6
|
def initialize(opts = {})
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
super(
|
7
|
+
local_opts = {}
|
8
|
+
local_opts[:rels] = opts[:rels] if opts.key?(:rels)
|
9
|
+
local_opts[:collection] = opts[:collection] if opts.key?(:collection)
|
10
|
+
super(local_opts)
|
11
11
|
end
|
12
12
|
|
13
13
|
def each
|
@@ -18,7 +18,6 @@ module Yaks
|
|
18
18
|
@collection
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
21
|
def null_resource?
|
23
22
|
true
|
24
23
|
end
|
data/lib/yaks/pipeline.rb
CHANGED
@@ -28,12 +28,12 @@ module Yaks
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def transitive?
|
31
|
-
steps.all? {|
|
31
|
+
steps.all? {|_name, step| step.respond_to?(:transitive?) && step.transitive?}
|
32
32
|
end
|
33
33
|
|
34
34
|
def inverse
|
35
35
|
unless transitive?
|
36
|
-
raise
|
36
|
+
raise "Unable to get inverse pipeline, not all pipeline steps are transitive."
|
37
37
|
end
|
38
38
|
|
39
39
|
self.class.new(steps.map {|name, step| [name, step.inverse]}.reverse)
|
data/lib/yaks/primitivize.rb
CHANGED
@@ -8,14 +8,15 @@ module Yaks
|
|
8
8
|
|
9
9
|
def call(object)
|
10
10
|
mappings.each do |pattern, block|
|
11
|
+
# rubocop:disable Style/CaseEquality
|
11
12
|
return instance_exec(object, &block) if pattern === object
|
12
13
|
end
|
13
14
|
raise PrimitivizeError, "don't know how to turn #{object.class} (#{object.inspect}) into a primitive"
|
14
15
|
end
|
15
16
|
|
16
|
-
def map(*types, &
|
17
|
+
def map(*types, &block)
|
17
18
|
types.each do |type|
|
18
|
-
mappings
|
19
|
+
@mappings = mappings.merge(type => block)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
data/lib/yaks/reader/hal.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module Yaks
|
2
2
|
module Reader
|
3
3
|
class Hal
|
4
|
+
include Util
|
4
5
|
|
5
|
-
def call(parsed_json,
|
6
|
+
def call(parsed_json, _env = {})
|
6
7
|
attributes = parsed_json.dup
|
7
8
|
links = convert_links(attributes.delete('_links') || {})
|
8
9
|
embedded = convert_embedded(attributes.delete('_embedded') || {})
|
@@ -21,22 +22,20 @@ module Yaks
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def convert_links(links)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
]
|
25
|
+
links.flat_map do |rel, link|
|
26
|
+
array(link).map do |l|
|
27
|
+
options = symbolize_keys(slice_hash(l, 'title', 'templated'))
|
28
|
+
# if it looks like a keyword we'll assume it's a registered rel type
|
29
|
+
rel = rel.to_sym if rel =~ /\A\w+\z/
|
30
|
+
Resource::Link.new(rel: rel, uri: l['href'], options: options)
|
31
|
+
end
|
32
|
+
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def array(x)
|
36
36
|
x.instance_of?(Array) ? x : [x]
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
39
|
def convert_embedded(embedded)
|
41
40
|
embedded.flat_map do |rel, resource|
|
42
41
|
case resource
|
@@ -48,7 +47,8 @@ module Yaks
|
|
48
47
|
else
|
49
48
|
CollectionResource.new(
|
50
49
|
members: resource.map { |r|
|
51
|
-
call(r).with(type: Util.singularize(rel[/\w+$/]))
|
50
|
+
call(r).with(type: Util.singularize(rel[/\w+$/]))
|
51
|
+
}
|
52
52
|
)
|
53
53
|
end
|
54
54
|
else
|
@@ -56,7 +56,6 @@ module Yaks
|
|
56
56
|
end.with(rels: [rel])
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
data/lib/yaks/reader/json_api.rb
CHANGED
@@ -1,49 +1,66 @@
|
|
1
1
|
module Yaks
|
2
2
|
module Reader
|
3
3
|
class JsonAPI
|
4
|
-
def call(parsed_json,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
def call(parsed_json, _env = {})
|
5
|
+
included = parsed_json['included'].nil? ? {} : parsed_json['included'].dup
|
6
|
+
|
7
|
+
if parsed_json['data'].is_a?(Array)
|
8
|
+
CollectionResource.new(
|
9
|
+
attributes: parsed_json['meta'].nil? ? nil : {meta: parsed_json['meta']},
|
10
|
+
members: parsed_json['data'].map { |data| call('data' => data, 'included' => included) }
|
11
|
+
)
|
12
|
+
else
|
13
|
+
attributes = parsed_json['data'].dup
|
14
|
+
links = attributes.delete('links') || {}
|
15
|
+
type = attributes.delete('type')
|
16
|
+
attributes.merge!(attributes.delete('attributes') || {})
|
17
|
+
|
18
|
+
association_links, resource_links = links.partition { |_k, v| v.is_a?(Hash) }
|
19
|
+
embedded = convert_embedded(Hash[association_links], included)
|
20
|
+
links = convert_links(Hash[resource_links])
|
21
|
+
|
22
|
+
Resource.new(
|
23
|
+
type: Util.singularize(type),
|
11
24
|
attributes: Util.symbolize_keys(attributes),
|
12
25
|
subresources: embedded,
|
13
|
-
links:
|
14
|
-
|
26
|
+
links: links
|
27
|
+
)
|
28
|
+
end
|
15
29
|
end
|
16
30
|
|
17
|
-
def convert_embedded(links,
|
31
|
+
def convert_embedded(links, included)
|
18
32
|
links.flat_map do |rel, link_data|
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
# A Link doesn't have to contain a `linkage` member.
|
34
|
+
# It can contain URLs instead, or as well, but we are only worried about *embedded* links here.
|
35
|
+
linkage = link_data['linkage']
|
36
|
+
# Resource linkage MUST be represented as one of the following:
|
37
|
+
#
|
38
|
+
# * `null` for empty to-one relationships.
|
39
|
+
# * a "linkage object" for non-empty to-one relationships.
|
40
|
+
# * an empty array ([]) for empty to-many relationships.
|
41
|
+
# * an array of linkage objects for non-empty to-many relationships.
|
42
|
+
if linkage.nil?
|
43
|
+
nil
|
44
|
+
elsif linkage.is_a? Array
|
31
45
|
CollectionResource.new(
|
32
|
-
|
33
|
-
type
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
CollectionResource.new(
|
38
|
-
members: link_data['data'].map { |link|
|
39
|
-
resource = linked.find{ |item| (item['id'] == link['id']) && (item['type'] == link['type']) }
|
40
|
-
call({'data' => [resource], 'linked' => linked})
|
41
|
-
},
|
42
|
-
rels: [rel]
|
46
|
+
members: linkage.map { |link|
|
47
|
+
data = included.find{ |item| (item['id'] == link['id']) && (item['type'] == link['type']) }
|
48
|
+
call('data' => data, 'included' => included)
|
49
|
+
},
|
50
|
+
rels: [rel]
|
43
51
|
)
|
52
|
+
else
|
53
|
+
data = included.find{ |item| (item['id'] == linkage['id']) && (item['type'] == linkage['type']) }
|
54
|
+
call('data' => data, 'included' => included).with(rels: [rel])
|
44
55
|
end
|
45
56
|
end.compact
|
46
57
|
end
|
58
|
+
|
59
|
+
def convert_links(links)
|
60
|
+
links.map do |rel, link|
|
61
|
+
Resource::Link.new(rel: rel.to_sym, uri: link)
|
62
|
+
end
|
63
|
+
end
|
47
64
|
end
|
48
65
|
end
|
49
66
|
end
|
data/lib/yaks/resource.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Yaks
|
2
2
|
class Resource
|
3
|
-
include
|
3
|
+
include Attribs.new(
|
4
4
|
type: nil,
|
5
5
|
rels: [],
|
6
6
|
links: [],
|
@@ -46,7 +46,7 @@ module Yaks
|
|
46
46
|
def collection?
|
47
47
|
false
|
48
48
|
end
|
49
|
-
|
49
|
+
alias_method :collection, :collection?
|
50
50
|
|
51
51
|
def with_collection(*)
|
52
52
|
self
|
@@ -59,10 +59,10 @@ module Yaks
|
|
59
59
|
def members
|
60
60
|
raise UnsupportedOperationError, "Only Yaks::CollectionResource has members"
|
61
61
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
alias_method :each, :members
|
63
|
+
alias_method :map, :members
|
64
|
+
alias_method :each_with_object, :members
|
65
|
+
alias_method :with_members, :members
|
66
66
|
|
67
67
|
def merge_attributes(new_attrs)
|
68
68
|
with(attributes: @attributes.merge(new_attrs))
|
@@ -84,6 +84,5 @@ module Yaks
|
|
84
84
|
def add_subresource(subresource)
|
85
85
|
append_to(:subresources, subresource)
|
86
86
|
end
|
87
|
-
|
88
87
|
end
|
89
88
|
end
|
data/lib/yaks/resource/form.rb
CHANGED
@@ -14,21 +14,11 @@ module Yaks
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def fields_flat(fs = fields)
|
18
|
-
fs.each_with_object([]) do |field, acc|
|
19
|
-
if field.type.equal? :fieldset
|
20
|
-
acc.concat(fields_flat field.fields)
|
21
|
-
else
|
22
|
-
acc << field
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
17
|
def method?(meth)
|
28
|
-
!method.nil? && method.downcase.to_sym
|
18
|
+
!method.nil? && method.downcase.to_sym == meth.downcase.to_sym
|
29
19
|
end
|
30
20
|
|
31
|
-
def has_action?
|
21
|
+
def has_action? # rubocop:disable Style/PredicateName
|
32
22
|
!action.nil?
|
33
23
|
end
|
34
24
|
end
|