Module: Betterdocs::ResultRepresenter::ClassMethods

Defined in:
lib/betterdocs/result_representer.rb

Instance Method Summary collapse

Instance Method Details

#collection(name, **options, &block) ⇒ Object



50
51
52
53
54
# File 'lib/betterdocs/result_representer.rb', line 50

def collection(name, **options, &block)
  d = doc(:collection_property, name, **options, &block) and
    properties << d
  self
end

#doc(type, name, **options, &block) ⇒ Object



17
18
19
# File 'lib/betterdocs/result_representer.rb', line 17

def doc(type, name, **options, &block)
  docs.add_element(self, type, name, **options, &block)
end

#docsObject



21
22
23
# File 'lib/betterdocs/result_representer.rb', line 21

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


60
61
62
63
# File 'lib/betterdocs/result_representer.rb', line 60

def link(name, **options, &block)
  d = doc(:link, name, **options, &block) and links << d
  self
end


56
57
58
# File 'lib/betterdocs/result_representer.rb', line 56

def links
  @links ||= Set.new
end

#propertiesObject



40
41
42
# File 'lib/betterdocs/result_representer.rb', line 40

def properties
  @properties ||= Set.new
end

#property(name, **options, &block) ⇒ Object



44
45
46
47
48
# File 'lib/betterdocs/result_representer.rb', line 44

def property(name, **options, &block)
  d = doc(:property, name, **options, &block) and
    properties << d
  self
end