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.



11
12
13
14
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 11

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

Instance Attribute Details

#dataObject

Returns the value of attribute data.



9
10
11
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 9

def data
  @data
end

#nodesObject

Returns the value of attribute nodes.



9
10
11
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 9

def nodes
  @nodes
end

#root_nameObject

Returns the value of attribute root_name.



9
10
11
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 9

def root_name
  @root_name
end

Instance Method Details

#add(n) ⇒ Object

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



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

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

  @nodes[n[:name]] = RailsApiDoc::Controller::Response::Param.new(n[:name], n[:attr], n[:nested])
end

#each(&block) ⇒ Object



16
17
18
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 16

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

#extends(template) ⇒ Object



31
32
33
# File 'lib/rails_api_doc/controller/response/rabl_compiler.rb', line 31

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