Module: Betterdocs::ResultRepresenter::ClassMethods
- Defined in:
- lib/betterdocs/result_representer.rb
Instance Method Summary collapse
- #api_url_for(options = {}) ⇒ Object
- #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
#api_url_for(options = {}) ⇒ Object
64 65 66 |
# File 'lib/betterdocs/result_representer.rb', line 64 def api_url_for( = {}) Betterdocs::Global.url_for() end |
#collection(name, **options, &block) ⇒ Object
49 50 51 52 53 |
# File 'lib/betterdocs/result_representer.rb', line 49 def collection(name, **, &block) d = doc(:collection_property, name, **, &block) and properties << d self end |
#doc(type, name, **options, &block) ⇒ Object
16 17 18 |
# File 'lib/betterdocs/result_representer.rb', line 16 def doc(type, name, **, &block) docs.add_element(self, type, name, , &block) end |
#docs ⇒ Object
20 21 22 |
# File 'lib/betterdocs/result_representer.rb', line 20 def docs @docs ||= Betterdocs::ResultRepresenterCollector.new end |
#hashify(object) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/betterdocs/result_representer.rb', line 10 def hashify(object) super do |result| assign_properties result, object assign_links result, object end end |
#link(name, **options, &block) ⇒ Object
59 60 61 62 |
# File 'lib/betterdocs/result_representer.rb', line 59 def link(name, **, &block) d = doc(:link, name, **, &block) and links << d self end |
#links ⇒ Object
55 56 57 |
# File 'lib/betterdocs/result_representer.rb', line 55 def links @links ||= Set.new end |
#properties ⇒ Object
39 40 41 |
# File 'lib/betterdocs/result_representer.rb', line 39 def properties @properties ||= Set.new end |
#property(name, **options, &block) ⇒ Object
43 44 45 46 47 |
# File 'lib/betterdocs/result_representer.rb', line 43 def property(name, **, &block) d = doc(:property, name, **, &block) and properties << d self end |