Sha256: a33630fc39f1161bf53f66f3a4331a2080edd7358b2e63eb1e16d8d33685b155

Contents?: true

Size: 782 Bytes

Versions: 7

Compression:

Stored size: 782 Bytes

Contents

module LazyResource
  module Types
    class Array < ::Array
      def self.parse(o)
        o.to_a
      end
    end

    class String < ::String
      def self.parse(o)
        o.to_s
      end
    end

    class Fixnum < ::Fixnum
      def self.parse(o)
        o.to_i
      end
    end

    class Boolean
      def self.parse(o)
        if [true, '1', 'true'].include? o
          true
        else
          false
        end
      end
    end

    class Float < ::Float
      def self.parse(o)
        o.to_f
      end
    end

    class Hash < ::Hash
      def self.parse(o)
        o
      end
    end

    class DateTime < ::DateTime
      def self.parse(o)
        if o.is_a?(::DateTime)
          o
        else
          super(o)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lazy_resource-0.5.0 lib/lazy_resource/types.rb
lazy_resource-0.4.0 lib/lazy_resource/types.rb
lazy_resource-0.3.3 lib/lazy_resource/types.rb
lazy_resource-0.3.2 lib/lazy_resource/types.rb
lazy_resource-0.3.0 lib/lazy_resource/types.rb
lazy_resource-0.2.0 lib/lazy_resource/types.rb
lazy_resource-0.1.0 lib/lazy_resource/types.rb