Sha256: c6ee88599dff90821513b1a5ecac1a8f745042e64f0fd4e25dade09410b67f13

Contents?: true

Size: 556 Bytes

Versions: 1

Compression:

Stored size: 556 Bytes

Contents

module Aggro
  module Transform
    # Private: Transforms boolean representations.
    module Boolean
      module_function

      def deserialize(value)
        value if truthy?(value) || falsey?(value)
      end

      def serialize(value)
        value if truthy?(value) || falsey?(value)
      end

      def falsey?(value)
        value == false || value == 'false' || value == '0'
      end

      private :falsey?

      def truthy?(value)
        value == true || value == 'true' || value == '1'
      end

      private :truthy?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.4 lib/aggro/transform/boolean.rb