Class: Ea::Qea::Models::EaAttributeTag

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/ea/qea/models/ea_attribute_tag.rb

Overview

EA Attribute Tag model

Represents attribute-level tags (custom key-value metadata) in the t_attributetag table. These are metadata properties specific to GML/XML Schema encoding for attributes.

Examples:

Create from database row

row = {
  "PropertyID" => 1,
  "ElementID" => 367,
  "Property" => "isMetadata",
  "VALUE" => "false",
  "NOTES" => nil,
  "ea_guid" => "{GUID}"
}
tag = EaAttributeTag.from_db_row(row)

Constant Summary collapse

COLUMN_MAP =
{
  "PropertyID" => :property_id,
  "ElementID" => :element_id,
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

from_db_row, #primary_key, #sort_position

Class Method Details

.column_mapObject



46
47
48
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 46

def self.column_map
  COLUMN_MAP
end

.primary_key_columnSymbol

Returns Primary key column name.

Returns:

  • (Symbol)

    Primary key column name



31
32
33
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 31

def self.primary_key_column
  :property_id
end

.table_nameString

Returns Database table name.

Returns:

  • (String)

    Database table name



36
37
38
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 36

def self.table_name
  "t_attributetag"
end

Instance Method Details

#boolean?Boolean

Check if property is boolean type

Returns:

  • (Boolean)

    true if value is boolean



81
82
83
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 81

def boolean?
  !boolean_value.nil?
end

#boolean_valueBoolean?

Parse boolean value

Returns:

  • (Boolean, nil)

    Boolean value if parseable, nil otherwise



67
68
69
70
71
72
73
74
75
76
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 67

def boolean_value
  return nil if value.nil?

  case value.downcase
  when "true", "1", "yes"
    true
  when "false", "0", "no"
    false
  end
end

#integer_valueInteger?

Parse integer value

Returns:

  • (Integer, nil)

    Integer value if parseable, nil otherwise



88
89
90
91
92
93
94
95
96
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 88

def integer_value
  return nil if value.nil?

  begin
    Integer(value)
  rescue StandardError
    nil
  end
end

#nameString?

Get property name

Returns:

  • (String, nil)

    Property name



53
54
55
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 53

def name
  property
end

#property_valueString?

Get property value as string

Returns:

  • (String, nil)

    Property value



60
61
62
# File 'lib/ea/qea/models/ea_attribute_tag.rb', line 60

def property_value
  value
end