class Gyro::Parser::XCDataModel::Relationship

One Relationship between attributes in the xcdatamodel

Attributes

comment[RW]
deletion_rule[RW]
destination[RW]
entity_name[RW]
inverse_name[RW]
inverse_type[RW]
json_ignored[RW]
json_ignored?[RW]
json_key_path[RW]
name[RW]
optional[RW]
realm_ignored[RW]
realm_ignored?[RW]
support_annotation[RW]
type[RW]

Public Class Methods

new(relationship_xml, entity_name) click to toggle source

rubocop:disable Metrics/AbcSize

# File lib/gyro/parser/xcdatamodel/relationship.rb, line 30
def initialize(relationship_xml, entity_name)
  @entity_name = entity_name
  @name = relationship_xml.attributes['name'].to_s
  @optional = relationship_xml.attributes['optional'].to_s == 'YES'
  @deletion_rule = relationship_xml.attributes['deletionRule'].to_s
  @inverse_name = relationship_xml.attributes['inverseName'].to_s
  @inverse_type = relationship_xml.attributes['destinationEntity'].to_s
  @json_key_path = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'JSONKeyPath')
  @realm_ignored = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'realmIgnored').empty? ? false : true
  @json_ignored = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'JSONIgnored').empty? ? false : true
  @support_annotation = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'supportAnnotation')
  @comment = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'comment')
  load_type(relationship_xml)
  @destination = Gyro::Parser::XCDataModel.user_info(relationship_xml, 'destination')
  search_for_error
end

Public Instance Methods

inverse?() click to toggle source
# File lib/gyro/parser/xcdatamodel/relationship.rb, line 61
def inverse?
  @name.end_with?('_')
end
to_h() click to toggle source
# File lib/gyro/parser/xcdatamodel/relationship.rb, line 47
def to_h
  { 'entity_name' => entity_name, 'name' => name, 'type' => type.to_s,
    'optional' => optional, 'deletion_rule' => deletion_rule, 'comment' => comment,
    'inverse_name' => inverse_name, 'inverse_type' => inverse_type,
    'json_key_path' => json_key_path, 'json_ignored' => json_ignored,
    'support_annotation' => support_annotation,
    'realm_ignored' => realm_ignored, 'destination' => destination, 'inverse' => inverse? }
end
to_s() click to toggle source

rubocop:enable Metrics/AbcSize

# File lib/gyro/parser/xcdatamodel/relationship.rb, line 57
def to_s
  "\tRelationship => name=#{@name} | type=#{@type} | optional=#{@optional} | deletion_rule=#{@deletion_rule}\n"
end