Class: SchemaSerializer::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_serializer/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Definition

Returns a new instance of Definition.



5
6
7
8
9
# File 'lib/schema_serializer/definition.rb', line 5

def initialize(hash)
  @schemas = hash.each_with_object({}) { |(name, schema), obj|
    obj[name.to_s] = Schema.new(name, schema)
  }
end

Instance Attribute Details

#schemasObject (readonly)

Returns the value of attribute schemas.



3
4
5
# File 'lib/schema_serializer/definition.rb', line 3

def schemas
  @schemas
end

Instance Method Details

#schema(name) ⇒ Object



11
12
13
# File 'lib/schema_serializer/definition.rb', line 11

def schema(name)
  schemas[name] || (raise SchemaNotFound, name)
end