Class: EasyApiDoc::Parameter

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
app/models/easy_api_doc/parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

#[], #[]=, #defaults, included, #inherited_overridable, #load_children

Constructor Details

#initialize(*params) ⇒ Parameter

Returns a new instance of Parameter.



7
8
9
10
# File 'app/models/easy_api_doc/parameter.rb', line 7

def initialize(*params)
  super(*params)
  set_field_name
end

Instance Attribute Details

#field_nameObject

Returns the value of attribute field_name.



5
6
7
# File 'app/models/easy_api_doc/parameter.rb', line 5

def field_name
  @field_name
end

Instance Method Details

#nested?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/models/easy_api_doc/parameter.rb', line 12

def nested?
  self['type'] == nil
end

#parametersObject



16
17
18
19
20
21
22
# File 'app/models/easy_api_doc/parameter.rb', line 16

def parameters
  return [] unless nested?
  return @parameters if @parameters
  field_namespace = @field_namespace || []
  field_namespace << @name
  @parameters = load_children(EasyApiDoc::Parameter, nil, {:extra_attributes => {'field_namespace' => field_namespace}})
end

#scope_levelObject



24
25
26
# File 'app/models/easy_api_doc/parameter.rb', line 24

def scope_level
  (@attributes['field_namespace'] || []).size
end