Class: CoreData::DataModel::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/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)


6
7
8
9
10
11
12
# File 'lib/core_data/data_model/entity.rb', line 6

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.



4
5
6
# File 'lib/core_data/data_model/entity.rb', line 4

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/core_data/data_model/entity.rb', line 4

def name
  @name
end

#relationshipsObject (readonly)

Returns the value of attribute relationships.



4
5
6
# File 'lib/core_data/data_model/entity.rb', line 4

def relationships
  @relationships
end

Instance Method Details

#to_sObject



14
15
16
# File 'lib/core_data/data_model/entity.rb', line 14

def to_s
  @name
end