Sha256: 8552bf87aaa84c8af8428dfcff9959c8a3af1bc5ce633b7a309cdc9eac5cc82a

Contents?: true

Size: 930 Bytes

Versions: 6

Compression:

Stored size: 930 Bytes

Contents

require 'parameters/types/type'

module Parameters
  module Types
    class Object < Type

      #
      # The Ruby Class the Type represents.
      #
      # @return [Class]
      #   The Ruby Class that matches the Types name.
      #
      def self.to_ruby
        @ruby_class ||= ::Object.const_get(self.name.split('::').last)
      end

      #
      # Determines if the value is an Object.
      #
      # @return [true]
      #
      def self.===(value)
        value.kind_of?(to_ruby)
      end

      #
      # Coerces the value into an Object.
      #
      # @param [::Object] value
      #   The value to coerce.
      #
      # @return [value]
      #   Passes through the value.
      #
      def self.coerce(value)
        value
      end

      #
      # Determines if the value is an Object.
      #
      # @return [true]
      #
      def ===(value)
        value.kind_of?(to_ruby)
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parameters-0.4.4 lib/parameters/types/object.rb
parameters-0.4.3 lib/parameters/types/object.rb
parameters-0.4.2 lib/parameters/types/object.rb
parameters-0.4.0 lib/parameters/types/object.rb
parameters-0.3.1 lib/parameters/types/object.rb
parameters-0.3.0 lib/parameters/types/object.rb