Class: Wordnik::OperationParameter

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
lib/wordnik/operation_parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ OperationParameter

Returns a new instance of OperationParameter.



12
13
14
15
16
17
18
19
# File 'lib/wordnik/operation_parameter.rb', line 12

def initialize(attributes = {})
  attributes.each do |name, value|
    send("#{name.to_s.underscore.to_sym}=", value)
  end
  
  # Fudge body param into having the name :body      
  self.name = :body if self.name.blank?
end

Instance Attribute Details

#allow_multipleObject

Returns the value of attribute allow_multiple.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def allow_multiple
  @allow_multiple
end

#allowable_valuesObject

Returns the value of attribute allowable_values.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def allowable_values
  @allowable_values
end

#data_typeObject

Returns the value of attribute data_type.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def data_type
  @data_type
end

#default_valueObject

Returns the value of attribute default_value.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def default_value
  @default_value
end

#descriptionObject

Returns the value of attribute description.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def description
  @description
end

#internal_descriptionObject

Returns the value of attribute internal_description.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def internal_description
  @internal_description
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def name
  @name
end

#param_accessObject

Returns the value of attribute param_access.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def param_access
  @param_access
end

#param_typeObject

Returns the value of attribute param_type.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def param_type
  @param_type
end

#requiredObject

Returns the value of attribute required.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def required
  @required
end

#value_type_internalObject

Returns the value of attribute value_type_internal.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def value_type_internal
  @value_type_internal
end

#wrapper_nameObject

Returns the value of attribute wrapper_name.



9
10
11
# File 'lib/wordnik/operation_parameter.rb', line 9

def wrapper_name
  @wrapper_name
end

Instance Method Details

#human_nameObject



21
22
23
24
# File 'lib/wordnik/operation_parameter.rb', line 21

def human_name
  return "request body" if self.param_type == 'body'
  self.name.to_s
end

#persisted?Boolean

It’s an ActiveModel thing..

Returns:

  • (Boolean)


38
39
40
# File 'lib/wordnik/operation_parameter.rb', line 38

def persisted?
  false
end

#positional?Boolean

Is this a required positional param used in a convenience method?

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/wordnik/operation_parameter.rb', line 31

def positional?
  return true if self.param_type == 'body'
  return true if self.param_type == 'path' && self.name.to_s != 'format'
  false
end

#required?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/wordnik/operation_parameter.rb', line 26

def required?
  self.required || self.param_type == "path"
end