Class: RailsApiDoc::Controller::Response::CompiledAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_api_doc/controller/response/rabl_compiler.rb

Overview

template struct

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompiledAttributes

Returns a new instance of CompiledAttributes.



20
21
22
23
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 20

def initialize
  @nodes = {}
  # @cache_key = false
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



18
19
20
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 18

def data
  @data
end

#nodesObject

Returns the value of attribute nodes.



18
19
20
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 18

def nodes
  @nodes
end

#root_nameObject

Returns the value of attribute root_name.



18
19
20
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 18

def root_name
  @root_name
end

Instance Method Details

#add(n) ⇒ Object

def initialize_dup(other) super self.nodes = other.nodes.dup end



34
35
36
37
38
39
40
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 34

def add(n)
  if n[:attr] && n[:name] != n[:attr]
    n[:name] = "#{n[:name]}(#{n[:attr]})"
  end

  @nodes[n[:name]] = Node.new(n[:name], n[:attr], n[:nested])
end

#each(&block) ⇒ Object



25
26
27
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 25

def each(&block)
  @nodes.each &block
end

#extends(template) ⇒ Object



42
43
44
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 42

def extends(template)
  @nodes.merge! template.nodes
end