Class: Unit::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/unit-ruby/util/schema.rb

Defined Under Namespace

Classes: Attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSchema

Returns a new instance of Schema.



5
6
7
# File 'lib/unit-ruby/util/schema.rb', line 5

def initialize
  @attributes = []
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



16
17
18
# File 'lib/unit-ruby/util/schema.rb', line 16

def attributes
  @attributes
end

Instance Method Details

#add(name, type, readonly: false) ⇒ Object



13
14
15
# File 'lib/unit-ruby/util/schema.rb', line 13

def add(name, type, readonly: false)
  @attributes << Attribute.new(name, type, readonly)
end

#contains?(name) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/unit-ruby/util/schema.rb', line 9

def contains?(name)
  attributes.map(&:name).include? name
end