Class: Jschematic::Attributes::Ref

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/jschematic/attributes/ref.rb

Instance Attribute Summary

Attributes included from Element

#id, #parent

Instance Method Summary collapse

Methods included from Element

#required?, #schema_for, #title, #to_s

Constructor Details

#initialize(uri) ⇒ Ref

Returns a new instance of Ref.



10
11
12
# File 'lib/jschematic/attributes/ref.rb', line 10

def initialize(uri)
  @uri = Addressable::URI.parse(uri)
end

Instance Method Details

#accepts?(instance) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/jschematic/attributes/ref.rb', line 14

def accepts?(instance)
  schema = schema_for(@uri) || raise(SchemaNotFoundError.new(@uri))
  schema.accepts?(instance)
end