yaks 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +158 -56
  3. data/Rakefile +1 -3
  4. data/ataru_setup.rb +72 -0
  5. data/find_missing_tests.rb +34 -0
  6. data/lib/yaks.rb +8 -10
  7. data/lib/yaks/breaking_changes.rb +4 -6
  8. data/lib/yaks/builder.rb +1 -1
  9. data/lib/yaks/changelog.rb +1 -1
  10. data/lib/yaks/collection_mapper.rb +8 -5
  11. data/lib/yaks/collection_resource.rb +0 -1
  12. data/lib/yaks/config.rb +17 -7
  13. data/lib/yaks/configurable.rb +20 -14
  14. data/lib/yaks/default_policy.rb +82 -33
  15. data/lib/yaks/format.rb +7 -3
  16. data/lib/yaks/format/collection_json.rb +4 -4
  17. data/lib/yaks/format/hal.rb +1 -2
  18. data/lib/yaks/format/halo.rb +2 -4
  19. data/lib/yaks/format/json_api.rb +46 -27
  20. data/lib/yaks/html5_forms.rb +0 -2
  21. data/lib/yaks/mapper.rb +5 -5
  22. data/lib/yaks/mapper/association.rb +7 -7
  23. data/lib/yaks/mapper/association_mapper.rb +2 -0
  24. data/lib/yaks/mapper/attribute.rb +10 -4
  25. data/lib/yaks/mapper/config.rb +2 -2
  26. data/lib/yaks/mapper/form.rb +4 -10
  27. data/lib/yaks/mapper/form/config.rb +16 -17
  28. data/lib/yaks/mapper/form/dynamic_field.rb +1 -1
  29. data/lib/yaks/mapper/form/field.rb +16 -7
  30. data/lib/yaks/mapper/form/field/option.rb +5 -4
  31. data/lib/yaks/mapper/form/fieldset.rb +1 -1
  32. data/lib/yaks/mapper/form/legend.rb +18 -0
  33. data/lib/yaks/mapper/has_many.rb +1 -0
  34. data/lib/yaks/mapper/link.rb +7 -4
  35. data/lib/yaks/null_resource.rb +4 -5
  36. data/lib/yaks/pipeline.rb +2 -2
  37. data/lib/yaks/primitivize.rb +3 -2
  38. data/lib/yaks/reader/hal.rb +12 -13
  39. data/lib/yaks/reader/json_api.rb +50 -33
  40. data/lib/yaks/resource.rb +6 -7
  41. data/lib/yaks/resource/form.rb +2 -12
  42. data/lib/yaks/resource/form/field.rb +4 -3
  43. data/lib/yaks/resource/form/field/option.rb +1 -1
  44. data/lib/yaks/resource/form/fieldset.rb +1 -1
  45. data/lib/yaks/resource/form/legend.rb +18 -0
  46. data/lib/yaks/resource/has_fields.rb +13 -7
  47. data/lib/yaks/resource/link.rb +1 -1
  48. data/lib/yaks/runner.rb +5 -2
  49. data/lib/yaks/serializer.rb +2 -3
  50. data/lib/yaks/util.rb +7 -8
  51. data/lib/yaks/version.rb +1 -1
  52. data/spec/acceptance/acceptance_spec.rb +53 -38
  53. data/spec/acceptance/json_shared_examples.rb +45 -12
  54. data/spec/acceptance/models.rb +1 -1
  55. data/spec/integration/dynamic_form_fields_spec.rb +0 -1
  56. data/spec/integration/fieldset_spec.rb +18 -20
  57. data/spec/integration/map_to_resource_spec.rb +6 -6
  58. data/spec/json/{confucius.collection.json → confucius.collection_json.json} +0 -0
  59. data/spec/json/confucius.json_api.json +43 -27
  60. data/spec/json/list_of_quotes.collection_json.json +43 -0
  61. data/spec/json/list_of_quotes.hal.json +18 -0
  62. data/spec/json/list_of_quotes.json_api.json +25 -0
  63. data/spec/json/youtypeitwepostit.collection_json.json +45 -0
  64. data/spec/spec_helper.rb +4 -3
  65. data/spec/support/classes_for_policy_testing.rb +38 -14
  66. data/spec/support/deep_eql.rb +21 -18
  67. data/spec/support/pet_mapper.rb +2 -0
  68. data/spec/support/shared_contexts.rb +9 -9
  69. data/spec/unit/yaks/builder_spec.rb +41 -18
  70. data/spec/unit/yaks/collection_mapper_spec.rb +22 -19
  71. data/spec/unit/yaks/collection_resource_spec.rb +16 -8
  72. data/spec/unit/yaks/config_spec.rb +215 -19
  73. data/spec/unit/yaks/configurable_spec.rb +66 -7
  74. data/spec/unit/yaks/default_policy/derive_mapper_from_collection_spec.rb +47 -0
  75. data/spec/unit/yaks/default_policy/derive_mapper_from_item_spec.rb +114 -0
  76. data/spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb +29 -71
  77. data/spec/unit/yaks/default_policy_spec.rb +4 -5
  78. data/spec/unit/yaks/format/collection_json_spec.rb +35 -36
  79. data/spec/unit/yaks/format/hal_spec.rb +3 -3
  80. data/spec/unit/yaks/format/json_api_spec.rb +109 -68
  81. data/spec/unit/yaks/format_spec.rb +34 -0
  82. data/spec/unit/yaks/fp/callable_spec.rb +5 -3
  83. data/spec/unit/yaks/mapper/association_mapper_spec.rb +22 -4
  84. data/spec/unit/yaks/mapper/association_spec.rb +23 -11
  85. data/spec/unit/yaks/mapper/attribute_spec.rb +46 -7
  86. data/spec/unit/yaks/mapper/config_spec.rb +2 -3
  87. data/spec/unit/yaks/mapper/form/config_spec.rb +95 -0
  88. data/spec/unit/yaks/mapper/form/dynamic_field_spec.rb +30 -0
  89. data/spec/unit/yaks/mapper/form/field/option_spec.rb +48 -4
  90. data/spec/unit/yaks/mapper/form/field_spec.rb +43 -2
  91. data/spec/unit/yaks/mapper/form/fieldset_spec.rb +67 -8
  92. data/spec/unit/yaks/mapper/form/legend_spec.rb +52 -0
  93. data/spec/unit/yaks/mapper/form_spec.rb +84 -23
  94. data/spec/unit/yaks/mapper/has_many_spec.rb +39 -36
  95. data/spec/unit/yaks/mapper/has_one_spec.rb +28 -20
  96. data/spec/unit/yaks/mapper/link_spec.rb +68 -16
  97. data/spec/unit/yaks/mapper_spec.rb +118 -30
  98. data/spec/unit/yaks/null_resource_spec.rb +83 -52
  99. data/spec/unit/yaks/pipeline_spec.rb +101 -74
  100. data/spec/unit/yaks/primitivize_spec.rb +25 -6
  101. data/spec/unit/yaks/resource/form/field_spec.rb +5 -5
  102. data/spec/unit/yaks/resource/form/fieldset_spec.rb +7 -0
  103. data/spec/unit/yaks/resource/form/legend_spec.rb +8 -0
  104. data/spec/unit/yaks/resource/form_spec.rb +17 -37
  105. data/spec/unit/yaks/resource/has_fields_spec.rb +44 -3
  106. data/spec/unit/yaks/resource/link_spec.rb +11 -6
  107. data/spec/unit/yaks/resource_spec.rb +87 -98
  108. data/spec/unit/yaks/runner_spec.rb +112 -28
  109. data/spec/unit/yaks/serializer_spec.rb +1 -1
  110. data/spec/unit/yaks/util_spec.rb +30 -10
  111. data/spec/yaml/list_of_quotes.yaml +13 -0
  112. data/yaks.gemspec +21 -13
  113. metadata +129 -41
  114. data/lib/yaks/attributes.rb +0 -86
  115. data/lib/yaks/fp.rb +0 -26
  116. data/lib/yaks/identifier/link_relation.rb +0 -17
  117. data/resources/iana-link-relations.csv +0 -152
  118. data/spec/json/youtypeitwepostit.collection.json +0 -45
  119. data/spec/unit/yaks/attributes_spec.rb +0 -178
  120. data/spec/unit/yaks/fp_spec.rb +0 -29
data/lib/yaks/format.rb CHANGED
@@ -26,7 +26,11 @@ module Yaks
26
26
  @env = env
27
27
  serialize_resource(resource)
28
28
  end
29
- alias serialize call
29
+ alias_method :serialize, :call
30
+
31
+ # @abstract
32
+ def serialize_resource(_resource)
33
+ end
30
34
 
31
35
  class << self
32
36
  extend Util::Deprecated
@@ -76,8 +80,8 @@ module Yaks
76
80
  end
77
81
 
78
82
  def media_types
79
- Format.all.each_with_object({}) do
80
- |format, memo| memo[format.format_name] = format.media_type
83
+ Format.all.each_with_object({}) do |format, memo|
84
+ memo[format.format_name] = format.media_type
81
85
  end
82
86
  end
83
87
  deprecated_alias :mime_types, :media_types
@@ -29,7 +29,7 @@ module Yaks
29
29
  value: value
30
30
  }
31
31
  end
32
- result = { data: attrs }
32
+ result = {data: attrs}
33
33
  result[:href] = item.self_link.uri if item.self_link
34
34
  item.links.each do |link|
35
35
  next if link.rel.equal? :self
@@ -43,7 +43,7 @@ module Yaks
43
43
 
44
44
  def serialize_links(resource)
45
45
  resource.links.each_with_object([]) do |link, result|
46
- result << { href: link.uri, rel: link.rel }
46
+ result << {href: link.uri, rel: link.rel}
47
47
  end
48
48
  end
49
49
 
@@ -51,12 +51,12 @@ module Yaks
51
51
  resource.forms.each_with_object([]) do |form, result|
52
52
  next unless form_is_query? form
53
53
 
54
- result << { rel: form.name, href: form.action }
54
+ result << {rel: form.name, href: form.action}
55
55
  result.last[:prompt] = form.title if form.title
56
56
 
57
57
  form.fields_flat.each do |field|
58
58
  result.last[:data] = [] unless result.last.key? :data
59
- result.last[:data] << { name: field.name, value: nil.to_s }
59
+ result.last[:data] << {name: field.name, value: nil.to_s}
60
60
  result.last[:data].last[:prompt] = field.label if field.label
61
61
  end
62
62
  end
@@ -87,7 +87,7 @@ module Yaks
87
87
  def serialize_embedded(subresources)
88
88
  subresources.each_with_object({}) do |sub, memo|
89
89
  memo[sub.rels.first] = if sub.collection?
90
- sub.map( &method(:serialize_resource) )
90
+ sub.map(&method(:serialize_resource))
91
91
  elsif sub.null_resource?
92
92
  nil
93
93
  else
@@ -95,7 +95,6 @@ module Yaks
95
95
  end
96
96
  end
97
97
  end
98
-
99
98
  end
100
99
  end
101
100
  end
@@ -33,11 +33,9 @@ module Yaks
33
33
  fields: field.fields.map(&method(:serialize_form_field))
34
34
  }
35
35
  else
36
- field.to_h_compact.each_with_object({}) do |(attr,value), hsh|
36
+ field.to_h_compact.each_with_object({}) do |(attr, value), hsh|
37
37
  if attr == :options # <option>s of a <select>
38
- if !value.empty?
39
- hsh[:options] = value.map(&:to_h_compact)
40
- end
38
+ hsh[:options] = value.map(&:to_h_compact) unless value.empty?
41
39
  else
42
40
  hsh[attr] = value
43
41
  end
@@ -8,76 +8,95 @@ module Yaks
8
8
  # @param [Yaks::Resource] resource
9
9
  # @return [Hash]
10
10
  def call(resource, _env = nil)
11
- main_collection = resource.seq.map(&method(:serialize_resource))
11
+ output = {}
12
+ if resource.collection?
13
+ output[:data] = resource.map(&method(:serialize_resource))
14
+ output[:links] = serialize_links(resource.links) if resource.links.any?
15
+ else
16
+ output[:data] = serialize_resource(resource)
17
+ end
18
+ included = resource.seq.each_with_object([]) do |res, array|
19
+ serialize_included_subresources(res.subresources, array)
20
+ end
21
+ output[:included] = included if included.any?
22
+ output[:meta] = resource[:meta] if resource[:meta]
23
+
24
+ output
25
+ end
12
26
 
13
- { data: main_collection }.tap do |serialized|
14
- linked = resource.seq.each_with_object([]) do |res, array|
15
- serialize_linked_subresources(res.subresources, array)
16
- end
17
- serialized.merge!(linked: linked) unless linked.empty?
27
+ # @param [Yaks::Resource] resource
28
+ # @return [Hash]
29
+ def serialize_links(links)
30
+ links.each_with_object({}) do |link, hash|
31
+ hash[link.rel] = link.uri
18
32
  end
19
33
  end
20
34
 
21
35
  # @param [Yaks::Resource] resource
22
36
  # @return [Hash]
23
37
  def serialize_resource(resource)
24
- result = {type: pluralize(resource.type).to_sym}.merge(resource.attributes)
38
+ result = {}
39
+ result[:type] = pluralize(resource.type)
40
+ result[:id] = resource[:id].to_s if resource[:id]
25
41
 
26
- links = serialize_links(resource.subresources)
27
- result[:links] = links unless links.empty?
42
+ attributes = resource.attributes.reject { |k| k.equal?(:id) }
43
+ result[:attributes] = attributes if attributes.any?
28
44
 
29
- if resource.self_link && !result.key?(:href)
30
- result[:href] = resource.self_link.uri
31
- end
45
+ result[:links] = {}
46
+ result[:links].update(serialize_subresource_links(resource.subresources))
47
+ result[:links].update(serialize_links(resource.links))
48
+ result.delete(:links) if result[:links].empty?
32
49
 
33
50
  result
34
51
  end
35
52
 
36
53
  # @param [Yaks::Resource] subresource
37
54
  # @return [Hash]
38
- def serialize_links(subresources)
55
+ def serialize_subresource_links(subresources)
39
56
  subresources.each_with_object({}) do |resource, hsh|
40
57
  next if resource.null_resource?
41
- hsh[resource.type] = serialize_link(resource)
58
+ hsh[resource.rels.first.sub(/^rel:/, '')] = serialize_subresource_link(resource)
42
59
  end
43
60
  end
44
61
 
45
62
  # @param [Yaks::Resource] resource
46
63
  # @return [Array, String]
47
- def serialize_link(resource)
64
+ def serialize_subresource_link(resource)
48
65
  if resource.collection?
49
- {type: resource.type, ids: resource.map(&send_with_args(:[], :id))}
66
+ {linkage: resource.map{|r| {type: pluralize(r.type), id: r[:id].to_s} }}
50
67
  else
51
- {type: pluralize(resource.type), id: resource[:id]}
68
+ {linkage: {type: pluralize(resource.type), id: resource[:id].to_s}}
52
69
  end
53
70
  end
54
71
 
55
72
  # @param [Hash] subresources
56
73
  # @param [Array] array
57
74
  # @return [Array]
58
- def serialize_linked_subresources(subresources, array)
75
+ def serialize_included_subresources(subresources, array)
59
76
  subresources.each do |resources|
60
- serialize_linked_resources(resources, array)
77
+ serialize_included_resources(resources, array)
61
78
  end
62
79
  end
63
80
 
64
81
  # @param [Array] resources
65
- # @param [Array] linked
82
+ # @param [Array] included
66
83
  # @return [Array]
67
- def serialize_linked_resources(subresource, linked)
68
- subresource.seq.each_with_object(linked) do |resource, memo|
84
+ def serialize_included_resources(subresource, included)
85
+ subresource.seq.each_with_object(included) do |resource, memo|
69
86
  serialize_subresource(resource, memo)
70
87
  end
71
88
  end
72
89
 
73
- # {shows => [{id: 3, name: 'foo'}]}
90
+ # {shows => [{id: '3', name: 'foo'}]}
74
91
  #
75
92
  # @param [Yaks::Resource] resource
76
- # @param [Hash] linked
93
+ # @param [Hash] included
77
94
  # @return [Hash]
78
- def serialize_subresource(resource, linked)
79
- linked << serialize_resource(resource)
80
- serialize_linked_subresources(resource.subresources, linked)
95
+ def serialize_subresource(resource, included)
96
+ included << serialize_resource(resource) unless included.any? do |item|
97
+ item[:id].eql?(resource[:id].to_s) && item[:type].eql?(pluralize(resource.type))
98
+ end
99
+ serialize_included_subresources(resource.subresources, included)
81
100
  end
82
101
 
83
102
  def inverse
@@ -4,7 +4,6 @@ module Yaks
4
4
  #
5
5
  # Does not aim to be complete, does aim to be a strict subset.
6
6
  module HTML5Forms
7
-
8
7
  INPUT_TYPES = [
9
8
  :checkbox,
10
9
  :color,
@@ -53,6 +52,5 @@ module Yaks
53
52
  checked: false,
54
53
  disabled: false
55
54
  }
56
-
57
55
  end
58
56
  end
data/lib/yaks/mapper.rb CHANGED
@@ -4,7 +4,7 @@ module Yaks
4
4
 
5
5
  def_set :type
6
6
 
7
- def_forward :attributes => :add_attributes
7
+ def_forward attributes: :add_attributes
8
8
  def_forward :append_to
9
9
 
10
10
  def_add :link, create: Link, append_to: :links
@@ -45,7 +45,7 @@ module Yaks
45
45
  self.class.mapper_name(policy)
46
46
  end
47
47
 
48
- def call(object, env = {})
48
+ def call(object, _env = nil)
49
49
  @object = object
50
50
 
51
51
  return NullResource.new if object.nil?
@@ -55,20 +55,20 @@ module Yaks
55
55
  :map_subresources,
56
56
  :map_forms
57
57
  ].inject(Resource.new(type: mapper_name)) do |resource, method|
58
- send(method, resource)
58
+ __send__(method, resource)
59
59
  end
60
60
  end
61
61
 
62
62
  def load_attribute(name)
63
63
  respond_to?(name) ? public_send(name) : object.public_send(name)
64
64
  end
65
- alias load_association load_attribute
65
+ alias_method :load_association, :load_attribute
66
66
 
67
67
  def expand_value(value)
68
68
  Resolve(value, self)
69
69
  end
70
70
 
71
- def expand_uri(uri, expand)
71
+ def expand_uri(uri, expand = true)
72
72
  return if uri.nil?
73
73
  return Resolve(uri, self) if uri.respond_to?(:to_proc)
74
74
 
@@ -1,7 +1,7 @@
1
1
  module Yaks
2
2
  class Mapper
3
3
  class Association
4
- include Attributes.new(
4
+ include Attribs.new(
5
5
  name: Undefined,
6
6
  item_mapper: Undefined,
7
7
  rel: Undefined,
@@ -9,7 +9,8 @@ module Yaks
9
9
  link_if: Undefined,
10
10
  if: Undefined
11
11
  ),
12
- Util
12
+ Util,
13
+ AbstractType
13
14
 
14
15
  def self.create(name, options = {})
15
16
  if options.key?(:mapper)
@@ -22,7 +23,7 @@ module Yaks
22
23
  end
23
24
 
24
25
  def add_to_resource(resource, parent_mapper, context)
25
- return resource if self.if != Undefined && !parent_mapper.expand_value(self.if)
26
+ return resource unless parent_mapper.expand_value(self.if)
26
27
  AssociationMapper.new(parent_mapper, self, context).call(resource)
27
28
  end
28
29
 
@@ -35,16 +36,15 @@ module Yaks
35
36
  policy.derive_rel_from_association(self)
36
37
  end
37
38
 
38
- # @abstract
39
- def map_resource(_object, _context)
40
- end
39
+ # @param object
40
+ # @param context
41
+ abstract_method :map_resource
41
42
 
42
43
  # support for HasOne and HasMany
43
44
  def resolve_association_mapper(policy)
44
45
  return item_mapper unless item_mapper.equal?(Undefined)
45
46
  policy.derive_mapper_from_association(self)
46
47
  end
47
-
48
48
  end
49
49
  end
50
50
  end
@@ -24,6 +24,8 @@ module Yaks
24
24
  end
25
25
  end
26
26
 
27
+ private
28
+
27
29
  def add_link(resource)
28
30
  Link.create(rel, association.href)
29
31
  .add_to_resource(resource, parent_mapper, nil)
@@ -1,14 +1,20 @@
1
1
  module Yaks
2
2
  class Mapper
3
3
  class Attribute
4
- include Attributes.new(:name)
4
+ include Attribs.new(:name, :block)
5
+ include Util
5
6
 
6
- def initialize(name)
7
- super(name: name)
7
+ def self.create(name, _options = nil, &block)
8
+ new(name: name, block: block)
8
9
  end
9
10
 
10
11
  def add_to_resource(resource, mapper, _context)
11
- resource.merge_attributes(name => mapper.load_attribute(name))
12
+ if block
13
+ attribute = Resolve(block, mapper)
14
+ else
15
+ attribute = mapper.load_attribute(name)
16
+ end
17
+ resource.merge_attributes(name => attribute)
12
18
  end
13
19
  end
14
20
  end
@@ -1,12 +1,12 @@
1
1
  module Yaks
2
2
  class Mapper
3
3
  class Config
4
- include Attributes.new(
4
+ include Attribs.new(
5
5
  type: nil, attributes: [], links: [], associations: [], forms: []
6
6
  )
7
7
 
8
8
  def add_attributes(*attrs)
9
- append_to(:attributes, *attrs.map(&Attribute.method(:new)))
9
+ append_to(:attributes, *attrs.map(&Attribute.method(:create)))
10
10
  end
11
11
  end
12
12
  end
@@ -3,24 +3,19 @@ module Yaks
3
3
  class Form
4
4
  extend Forwardable, Util
5
5
 
6
-
7
6
  def_delegators :config, :name, :action, :title, :method,
8
7
  :media_type, :fields, :dynamic_blocks
9
8
 
10
9
  def self.create(*args, &block)
11
10
  args, options = extract_options(args)
12
-
13
- if args.first.is_a? Symbol
14
- options[:name] = args.first
15
- end
16
-
11
+ options[:name] = args.first if args.first
17
12
  new(config: Config.build(options, &block))
18
13
  end
19
14
 
20
15
  ############################################################
21
16
  # instance
22
17
 
23
- include Attributes.new(:config)
18
+ include Attribs.new(:config)
24
19
 
25
20
  def add_to_resource(resource, mapper, _context)
26
21
  return resource if config.if && !mapper.expand_value(config.if)
@@ -30,16 +25,15 @@ module Yaks
30
25
  def to_resource_form(mapper)
31
26
  attrs = {
32
27
  fields: config.to_resource_fields(mapper),
33
- action: mapper.expand_uri(config.action, true)
28
+ action: mapper.expand_uri(action)
34
29
  }
35
30
 
36
31
  [:name, :title, :method, :media_type].each do |attr|
37
- attrs[attr] = mapper.expand_value(config.public_send(attr))
32
+ attrs[attr] = mapper.expand_value(public_send(attr))
38
33
  end
39
34
 
40
35
  Resource::Form.new(attrs)
41
36
  end
42
-
43
37
  end
44
38
  end
45
39
  end
@@ -2,30 +2,29 @@ module Yaks
2
2
  class Mapper
3
3
  class Form
4
4
  class Config
5
- include Attributes.new(
5
+ include Attribs.new(
6
6
  name: nil,
7
7
  action: nil,
8
8
  title: nil,
9
9
  method: nil,
10
10
  media_type: nil,
11
- fields: [],
11
+ fields: [].freeze,
12
12
  if: nil
13
13
  )
14
14
 
15
- def self.builder
16
- @builder ||= Builder.new(self) do
17
- def_set :action, :title, :method, :media_type
18
- def_add :field, create: Field::Builder, append_to: :fields
19
- def_add :fieldset, create: Fieldset, append_to: :fields
20
- HTML5Forms::INPUT_TYPES.each do |type|
21
- def_add(type,
22
- create: Field::Builder,
23
- append_to: :fields,
24
- defaults: { type: type })
25
- end
26
- def_add :dynamic, create: DynamicField, append_to: :fields
27
- def_forward :condition
15
+ Builder = Yaks::Builder.new(self) do
16
+ def_set :action, :title, :method, :media_type
17
+ def_add :field, create: Field::Builder, append_to: :fields
18
+ def_add :fieldset, create: Fieldset, append_to: :fields
19
+ HTML5Forms::INPUT_TYPES.each do |type|
20
+ def_add(type,
21
+ create: Field::Builder,
22
+ append_to: :fields,
23
+ defaults: {type: type})
28
24
  end
25
+ def_add :legend, create: Legend, append_to: :fields
26
+ def_add :dynamic, create: DynamicField, append_to: :fields
27
+ def_forward :condition
29
28
  end
30
29
 
31
30
  # Builder expects a `create' method. Alias to constructor
@@ -36,13 +35,13 @@ module Yaks
36
35
  # Build up a configuration based on an initial set of
37
36
  # attributes, and a configuration block
38
37
  def self.build(options = {}, &block)
39
- builder.create(options, &block)
38
+ Builder.create(options, &block)
40
39
  end
41
40
 
42
41
  # Build up a configuration based on a config block. Provide an
43
42
  # object to be supplied to the block
44
43
  def self.build_with_object(object, &block)
45
- builder.build(new, object, &block)
44
+ Builder.build(new, object, &block)
46
45
  end
47
46
 
48
47
  def condition(prc = nil, &blk)