module JsonSchema::Attributes
def self.included(klass)
def self.included(klass) klass.extend(ClassMethods) klass.send(:initialize_attrs) end
def [](name)
This is implemented so that `JsonPointer::Evaluator` can evaluate a
class are not available (e.g. `expanded`.)
that are part of the JSON schema specification; other methods on the
procured with `schema[:additionalItems]`. This only works for attributes
string. So for example, the value of `schema.additional_items` could be
Allows the values of schema attributes to be accessed with a symbol or a
def [](name) name = name.to_sym if self.class.schema_attrs.key?(name) send(self.class.schema_attrs[name]) else raise NoMethodError, "Schema does not respond to ##{name}" end end
def copy_from(schema)
def copy_from(schema) self.class.copyable_attrs.each do |copyable, _| instance_variable_set(copyable, schema.instance_variable_get(copyable)) end end
def initialize_attrs
def initialize_attrs self.class.copyable_attrs.each do |attr, _| instance_variable_set(attr, nil) end end