Sha256: a53ffd5e5921f308c32eb56c5f13e17ef38a5f3fe0edc929fb720cd841209945

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

require 'active_support/core_ext/hash/indifferent_access'

module ApipieBindings

  class Param

    attr_reader :name, :params, :expected_type, :description, :validator

    def initialize(param)
      param = param.with_indifferent_access
      @name = param[:name]
      params = param[:params] || []
      @params = params.map { |p| ApipieBindings::Param.new(p) }
      @expected_type = param[:expected_type].to_sym
      @description = param[:description].gsub(/<\/?[^>]+?>/, "")
      @required = param[:required]
      @validator = param[:validator]
    end

    def required?
      @required
    end

    def to_s
      "<Param #{ required? ? '*' : '' }#{@name} (#{@expected_type.capitalize})>"
    end

    def inspect
      to_s
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apipie-bindings-0.0.1 lib/apipie_bindings/param.rb