Class: Lutaml::Qea::Models::EaAttributeTag

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#primary_key

Class Method Details

.from_db_row(row) ⇒ EaAttributeTag?

Create from database row

Parameters:

  • row (Hash)

    Database row with string keys

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/lutaml/qea/models/ea_attribute_tag.rb', line 44

def self.from_db_row(row)
  return nil if row.nil?

  new(
    property_id: row["PropertyID"],
    element_id: row["ElementID"],
    property: row["Property"],
    value: row["VALUE"],
    notes: row["NOTES"],
    ea_guid: row["ea_guid"],
  )
end

.primary_key_columnSymbol

Returns Primary key column name.

Returns:

  • (Symbol)

    Primary key column name



31
32
33
# File 'lib/lutaml/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/lutaml/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



88
89
90
# File 'lib/lutaml/qea/models/ea_attribute_tag.rb', line 88

def boolean?
  !boolean_value.nil?
end

#boolean_valueBoolean?

Parse boolean value

Returns:

  • (Boolean, nil)

    Boolean value if parseable, nil otherwise



74
75
76
77
78
79
80
81
82
83
# File 'lib/lutaml/qea/models/ea_attribute_tag.rb', line 74

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



95
96
97
98
99
100
101
102
103
# File 'lib/lutaml/qea/models/ea_attribute_tag.rb', line 95

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



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

def name
  property
end

#property_valueString?

Get property value as string

Returns:

  • (String, nil)

    Property value



67
68
69
# File 'lib/lutaml/qea/models/ea_attribute_tag.rb', line 67

def property_value
  value
end