Class: Rack::CoreData::DataModel::Relationship

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relationship) ⇒ Relationship

Returns a new instance of Relationship.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rack/core-data/data_model/relationship.rb', line 5

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

  @name = relationship['name']
  @destination = relationship['destinationEntity']
  @inverse = relationship['inverseName']
  @deletion_rule = relationship['deletionRule'].downcase.to_sym

  @min_count = relationship['minCount'].to_i
  @max_count = relationship['maxCount'].to_i

  @to_many = relationship['toMany'] == "YES"
  @optional = relationship['optional'] == "YES"
  @syncable = relationship['syncable'] == "YES"
end

Instance Attribute Details

#deletion_ruleObject (readonly)

Returns the value of attribute deletion_rule.



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

def deletion_rule
  @deletion_rule
end

#destinationObject (readonly)

Returns the value of attribute destination.



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

def destination
  @destination
end

#inverseObject (readonly)

Returns the value of attribute inverse.



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

def inverse
  @inverse
end

#max_countObject (readonly)

Returns the value of attribute max_count.



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

def max_count
  @max_count
end

#min_countObject (readonly)

Returns the value of attribute min_count.



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

def min_count
  @min_count
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#to_many?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rack/core-data/data_model/relationship.rb', line 25

def to_many?
  !!@to_many
end

#to_one?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rack/core-data/data_model/relationship.rb', line 29

def to_one?
  !to_many?
end

#to_sObject



21
22
23
# File 'lib/rack/core-data/data_model/relationship.rb', line 21

def to_s
  @name
end