Sha256: 9ec84112853ad6539e7bf6cdf4279078113e39f85b02a04b40f4d7cdf3c30764

Contents?: true

Size: 673 Bytes

Versions: 13

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true
module Hako
  module Schema
    class Structure
      def initialize
        @members = {}
      end

      def valid?(object)
        unless object.is_a?(::Hash)
          return false
        end
        @members.each do |key, val_schema|
          unless val_schema.valid?(object[key])
            return false
          end
        end
        true
      end

      def same?(x, y)
        @members.each do |key, val_schema|
          unless val_schema.same?(x[key], y[key])
            return false
          end
        end
        true
      end

      def member(key, schema)
        @members[key] = schema
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hako-1.1.0 lib/hako/schema/structure.rb
hako-1.0.1 lib/hako/schema/structure.rb
hako-1.0.0 lib/hako/schema/structure.rb
hako-0.27.0 lib/hako/schema/structure.rb
hako-0.26.0 lib/hako/schema/structure.rb
hako-0.25.2 lib/hako/schema/structure.rb
hako-0.25.1 lib/hako/schema/structure.rb
hako-0.25.0 lib/hako/schema/structure.rb
hako-0.24.0 lib/hako/schema/structure.rb
hako-0.23.0 lib/hako/schema/structure.rb
hako-0.22.0 lib/hako/schema/structure.rb
hako-0.21.1 lib/hako/schema/structure.rb
hako-0.21.0 lib/hako/schema/structure.rb