Sha256: 21600d5424104216c43fdb42b079272146838aee1b0456e94cd48f9025a6abf4

Contents?: true

Size: 1.12 KB

Versions: 14

Compression:

Stored size: 1.12 KB

Contents

module Wordnik

  class OperationParameter
    require 'active_model'
    include ActiveModel::Validations
    include ActiveModel::Conversion
    extend ActiveModel::Naming

    attr_accessor :name, :description, :required, :param_type, :default_value, :allowable_values, 
    :param_access, :internal_description, :wrapper_name, :data_type, :allow_multiple, :value_type_internal

    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

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

    def required?
      self.required || self.param_type == "path"
    end
    
    # Is this a required positional param used in a convenience method?
    def positional?
      return true if self.param_type == 'body'
      return true if self.param_type == 'path' && self.name.to_s != 'format'
      false
    end

    # It's an ActiveModel thing..
    def persisted?
      false
    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wordnik-4.12 lib/wordnik/operation_parameter.rb
wordnik-4.11 lib/wordnik/operation_parameter.rb
wordnik-4.10 lib/wordnik/operation_parameter.rb
wordnik-4.09 lib/wordnik/operation_parameter.rb
wordnik-4.08 lib/wordnik/operation_parameter.rb
wordnik-4.07 lib/wordnik/operation_parameter.rb
wordnik-4.06.15 lib/wordnik/operation_parameter.rb
wordnik-4.06.14 lib/wordnik/operation_parameter.rb
wordnik-4.06.13 lib/wordnik/operation_parameter.rb
wordnik-4.06.12 lib/wordnik/operation_parameter.rb
wordnik-4.06.11 lib/wordnik/operation_parameter.rb
wordnik-4.06.10 lib/wordnik/operation_parameter.rb
wordnik-4.06.08 lib/wordnik/operation_parameter.rb
wordnik-4.06.07 lib/wordnik/operation_parameter.rb