class Gyro::Parser::XCDataModel::Attribute
Attributes
comment[RW]
default[RW]
entity_name[RW]
enum_type[RW]
enum_values[RW]
indexed[RW]
indexed?[RW]
json_ignored[RW]
json_ignored?[RW]
json_key_path[RW]
json_values[RW]
name[RW]
optional[RW]
optional?[RW]
realm_ignored[RW]
realm_ignored?[RW]
realm_read_only[RW]
support_annotation[RW]
transformer[RW]
type[RW]
Public Class Methods
new(attribute_xml, entity_name)
click to toggle source
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 31 def initialize(attribute_xml, entity_name) @entity_name = entity_name @name = attribute_xml.attributes['name'].to_s @optional = attribute_xml.attributes['optional'].to_s == 'YES' @indexed = attribute_xml.attributes['indexed'].to_s == 'YES' @default = attribute_xml.attributes['defaultValueString'].to_s @type = attribute_xml.attributes['attributeType'].to_s.downcase.tr(' ', '_').to_sym @realm_ignored = !Gyro::Parser::XCDataModel.user_info(attribute_xml, 'realmIgnored').empty? @realm_read_only = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'realmReadOnly') @enum_type = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'enumType') @enum_values = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'enumValues').split(',') @json_key_path = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'JSONKeyPath') @json_values = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'JSONValues').split(',') @json_ignored = !Gyro::Parser::XCDataModel.user_info(attribute_xml, 'JSONIgnored').empty? @transformer = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'transformer').strip @comment = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'comment') @support_annotation = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'supportAnnotation') search_for_error end
Public Instance Methods
bool?()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 105 def bool? @type == :boolean end
decimal?()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 93 def decimal? (@type == :decimal) || (@type == :double) || (@type == :float) end
default?()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 78 def default? !@default.empty? end
enum?()
click to toggle source
rubocop:enable Metrics/AbcSize, Metrics/MethodLength
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 70 def enum? !@enum_type.empty? end
integer?()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 97 def integer? (@type == :integer_16) || (@type == :integer_32) || (@type == :integer_64) end
need_transformer?()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 109 def need_transformer? !@enum_type.empty? || (@type == :boolean) || (@type == :date) || !@transformer.empty? end
number?()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 101 def number? decimal? || integer? end
read_only?()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 74 def read_only? !@realm_read_only.empty? end
to_h()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 51 def to_h { 'entity_name' => entity_name, 'name' => name, 'type' => type.to_s, 'optional' => optional, 'indexed' => indexed, 'default' => default, 'realm_ignored' => realm_ignored, 'realm_read_only' => realm_read_only, 'enum_type' => enum_type, 'enum_values' => enum_values, 'json_key_path' => json_key_path, 'json_values' => json_values, 'json_ignored' => json_ignored, 'transformer' => transformer, 'need_transformer' => need_transformer?, 'comment' => comment, 'support_annotation' => support_annotation, 'is_decimal' => decimal?, 'is_integer' => integer?, 'is_number' => number?, 'is_bool' => bool? } end
to_s()
click to toggle source
# File lib/gyro/parser/xcdatamodel/attribute.rb, line 82 def to_s items = [ "name=#{@name}", "type=#{@type}", "optional=#{@optional}", "default=#{@default}", "indexed=#{@indexed}" ] "\tAttribute => " + items.join(' | ') + "\n" end