Module: Betterdocs::ResultRepresenter::ClassMethods
- Defined in:
- lib/betterdocs/result_representer.rb
Instance Method Summary collapse
- #collection(name, **options, &block) ⇒ Object
- #doc(type, name, **options, &block) ⇒ Object
- #docs ⇒ Object
- #hashify(object) ⇒ Object
- #link(name, **options, &block) ⇒ Object
- #links ⇒ Object
- #properties ⇒ Object
- #property(name, **options, &block) ⇒ Object
Instance Method Details
#collection(name, **options, &block) ⇒ Object
51 52 53 54 55 |
# File 'lib/betterdocs/result_representer.rb', line 51 def collection(name, **, &block) d = doc(:collection_property, name, **, &block) and properties << d self end |
#doc(type, name, **options, &block) ⇒ Object
18 19 20 |
# File 'lib/betterdocs/result_representer.rb', line 18 def doc(type, name, **, &block) docs.add_element(self, type, name, **, &block) end |
#docs ⇒ Object
22 23 24 |
# File 'lib/betterdocs/result_representer.rb', line 22 def docs @docs ||= Betterdocs::ResultRepresenterCollector.new end |
#hashify(object) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/betterdocs/result_representer.rb', line 11 def hashify(object) super do |result| assign_properties result, object assign_links result, object end end |
#link(name, **options, &block) ⇒ Object
61 62 63 64 |
# File 'lib/betterdocs/result_representer.rb', line 61 def link(name, **, &block) d = doc(:link, name, **, &block) and links << d self end |
#links ⇒ Object
57 58 59 |
# File 'lib/betterdocs/result_representer.rb', line 57 def links @links ||= Set.new end |
#properties ⇒ Object
41 42 43 |
# File 'lib/betterdocs/result_representer.rb', line 41 def properties @properties ||= Set.new end |
#property(name, **options, &block) ⇒ Object
45 46 47 48 49 |
# File 'lib/betterdocs/result_representer.rb', line 45 def property(name, **, &block) d = doc(:property, name, **, &block) and properties << d self end |