compony 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/VERSION +1 -1
  4. data/compony.gemspec +4 -4
  5. data/doc/ComponentGenerator.html +3 -3
  6. data/doc/Components.html +3 -3
  7. data/doc/ComponentsGenerator.html +3 -3
  8. data/doc/Compony/Component.html +138 -45
  9. data/doc/Compony/ComponentMixins/Default/Labelling.html +3 -3
  10. data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +3 -3
  11. data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +3 -3
  12. data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +3 -3
  13. data/doc/Compony/ComponentMixins/Default/Standalone.html +3 -3
  14. data/doc/Compony/ComponentMixins/Default.html +3 -3
  15. data/doc/Compony/ComponentMixins/Resourceful.html +3 -3
  16. data/doc/Compony/ComponentMixins.html +3 -3
  17. data/doc/Compony/Components/Button.html +4 -4
  18. data/doc/Compony/Components/Destroy.html +4 -4
  19. data/doc/Compony/Components/Edit.html +20 -20
  20. data/doc/Compony/Components/Form.html +4 -4
  21. data/doc/Compony/Components/New.html +4 -4
  22. data/doc/Compony/Components/WithForm.html +4 -4
  23. data/doc/Compony/Components.html +3 -3
  24. data/doc/Compony/ControllerMixin.html +3 -3
  25. data/doc/Compony/Engine.html +3 -3
  26. data/doc/Compony/MethodAccessibleHash.html +3 -3
  27. data/doc/Compony/ModelFields/Anchormodel.html +3 -3
  28. data/doc/Compony/ModelFields/Association.html +3 -3
  29. data/doc/Compony/ModelFields/Attachment.html +3 -3
  30. data/doc/Compony/ModelFields/Base.html +3 -3
  31. data/doc/Compony/ModelFields/Boolean.html +3 -3
  32. data/doc/Compony/ModelFields/Color.html +3 -3
  33. data/doc/Compony/ModelFields/Currency.html +3 -3
  34. data/doc/Compony/ModelFields/Date.html +3 -3
  35. data/doc/Compony/ModelFields/Datetime.html +3 -3
  36. data/doc/Compony/ModelFields/Decimal.html +3 -3
  37. data/doc/Compony/ModelFields/Email.html +3 -3
  38. data/doc/Compony/ModelFields/Float.html +3 -3
  39. data/doc/Compony/ModelFields/Integer.html +3 -3
  40. data/doc/Compony/ModelFields/Percentage.html +3 -3
  41. data/doc/Compony/ModelFields/Phone.html +3 -3
  42. data/doc/Compony/ModelFields/RichText.html +3 -3
  43. data/doc/Compony/ModelFields/String.html +3 -3
  44. data/doc/Compony/ModelFields/Text.html +3 -3
  45. data/doc/Compony/ModelFields/Time.html +3 -3
  46. data/doc/Compony/ModelFields/Url.html +3 -3
  47. data/doc/Compony/ModelFields.html +3 -3
  48. data/doc/Compony/ModelMixin.html +3 -3
  49. data/doc/Compony/NaturalOrdering.html +3 -3
  50. data/doc/Compony/RequestContext.html +72 -5
  51. data/doc/Compony/Version.html +3 -3
  52. data/doc/Compony/ViewHelpers.html +3 -3
  53. data/doc/Compony.html +3 -3
  54. data/doc/ComponyController.html +3 -3
  55. data/doc/_index.html +4 -4
  56. data/doc/file.README.html +3 -3
  57. data/doc/frames.html +10 -5
  58. data/doc/index.html +3 -3
  59. data/doc/method_list.html +96 -80
  60. data/doc/top-level-namespace.html +3 -3
  61. data/lib/compony/component.rb +14 -3
  62. data/lib/compony/components/edit.rb +4 -0
  63. data/lib/compony/request_context.rb +8 -1
  64. metadata +3 -3
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.9.34
9
+ &mdash; Documentation by YARD 0.9.36
10
10
 
11
11
  </title>
12
12
 
@@ -102,9 +102,9 @@
102
102
  </div>
103
103
 
104
104
  <div id="footer">
105
- Generated on Fri May 31 14:28:29 2024 by
105
+ Generated on Mon Jun 3 15:20:40 2024 by
106
106
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
- 0.9.34 (ruby-3.2.2).
107
+ 0.9.36 (ruby-3.2.2).
108
108
  </div>
109
109
 
110
110
  </div>
@@ -141,9 +141,20 @@ module Compony
141
141
  # Removes a content block. Use this in subclasses if a content block defined in the parent should be removed from the child.
142
142
  # @param [Symbol,String] name Name of the content block that should be removed
143
143
  def remove_content(name)
144
- name = name.to_sym
145
- existing_index = @content_blocks.find_index { |el| el.name == name } || fail("Content block #{name.inspect} not found for removal in #{inspect}.")
146
- @content_blocks.delete_at(existing_index)
144
+ existing_index = @content_blocks.find_index { |el| el.name == name.to_sym }
145
+ if existing_index.nil?
146
+ return false
147
+ else
148
+ @content_blocks.delete_at(existing_index)
149
+ return true
150
+ end
151
+ end
152
+
153
+ # DSL method
154
+ # Removes a content block and fails if the content block was not found.
155
+ # @param [Symbol,String] name Name of the content block that should be removed
156
+ def remove_content!(name)
157
+ remove_content(name) || fail("Content block #{name.inspect} not found for removal in #{inspect}.")
147
158
  end
148
159
 
149
160
  # Renders the component using the controller passsed to it and returns it as a string.
@@ -35,6 +35,10 @@ module Compony
35
35
  Compony.button(:show, @data.send(data_class.owner_model_attr), icon: :xmark, color: :secondary, label: I18n.t('compony.cancel'))
36
36
  end
37
37
 
38
+ content :label do
39
+ h2 component.label
40
+ end
41
+
38
42
  content do
39
43
  concat form_comp.render(controller, data: @data)
40
44
  end
@@ -45,7 +45,9 @@ module Compony
45
45
  # Renders a content block from the current component.
46
46
  def content(name)
47
47
  name = name.to_sym
48
- content_block = component.content_blocks.find { |el| el.name == name } || fail("Content block #{name.inspect} not found in #{component.inspect}.")
48
+ content_block = component.content_blocks.find { |el| el.name == name }
49
+ return false if content_block.nil?
50
+
49
51
  # We have to clear Rails' output_buffer to prevent double rendering of blocks. To achieve this, a fresh render context is instanciated.
50
52
  concat controller.render_to_string(
51
53
  type: :dyny,
@@ -54,6 +56,11 @@ module Compony
54
56
  Compony::RequestContext.new(render_component, render_controller, helpers: self, locals: local_assigns).evaluate_with_backfire(&render_block.payload)
55
57
  RUBY
56
58
  )
59
+ return true
60
+ end
61
+
62
+ def content!(name)
63
+ content(name) || fail("Content block #{name.inspect} not found in #{component.inspect}.")
57
64
  end
58
65
  end
59
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Kalbermatter
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-05-31 00:00:00.000000000 Z
12
+ date: 2024-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yard
@@ -330,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
330
  - !ruby/object:Gem::Version
331
331
  version: '0'
332
332
  requirements: []
333
- rubygems_version: 3.5.9
333
+ rubygems_version: 3.5.11
334
334
  signing_key:
335
335
  specification_version: 4
336
336
  summary: Compony is a Gem that allows you to write your Rails application in component-style