Sha256: 4ffeb25958fdc14e528324f1e4ec4c88c0828d17b4a642aa2ab4d8e6950a0ee9

Contents?: true

Size: 643 Bytes

Versions: 1

Compression:

Stored size: 643 Bytes

Contents

class Boolean; end unless defined?(Boolean)

begin
  require 'uuidtools'
rescue LoadError
  nil
else
  module Granite
    module Form
      class UUID < UUIDTools::UUID
        def as_json(*_)
          to_s
        end

        def to_param
          to_s
        end

        def self.parse_string(value)
          return nil if value.empty?

          if value.length == 36
            parse value
          elsif value.length == 32
            parse_hexdigest value
          else
            parse_raw value
          end
        end

        def inspect
          "#<Granite::Form::UUID:#{self}>"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
granite-form-0.6.0 lib/granite/form/extensions.rb