Sha256: ea60885b2f1164de4a8d51477fa91df83058a354b2d213bed99714f9dd8169f8

Contents?: true

Size: 559 Bytes

Versions: 1

Compression:

Stored size: 559 Bytes

Contents

require 'jschematic/exceptions'

module Jschematic
  module Element
    attr_accessor :parent
    attr_writer   :id

    def required?
      false
    end

    def title
      nil
    end

    def id
      if @parent.respond_to?(:id)
        @parent.id + @id
      else
        @id
      end
    end

    def to_s
      self.class.to_s
    end

    def schema_for(ref)
      parent && parent.schema_for(ref)
    end

    private

    def fail_validation!(expected, actual)
      raise Jschematic::ValidationError.new(self, expected, actual)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jschematic-0.1.0 lib/jschematic/element.rb