Class: Rack::CoreData::DataModel::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/core-data/data_model/entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity) ⇒ Entity

Returns a new instance of Entity.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/rack/core-data/data_model/entity.rb', line 5

def initialize(entity)
  raise ArgumentError unless ::Nokogiri::XML::Element === entity

  @name = entity['name']
  @attributes = entity.xpath('attribute').collect{|element| Attribute.new(element)}
  @relationships = entity.xpath('relationship').collect{|element| Relationship.new(element)}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/rack/core-data/data_model/entity.rb', line 3

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rack/core-data/data_model/entity.rb', line 3

def name
  @name
end

#relationshipsObject (readonly)

Returns the value of attribute relationships.



3
4
5
# File 'lib/rack/core-data/data_model/entity.rb', line 3

def relationships
  @relationships
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/rack/core-data/data_model/entity.rb', line 13

def to_s
  @name
end