Class: Mingle::PropertyDefinition
- Inherits:
-
Object
- Object
- Mingle::PropertyDefinition
- Defined in:
- lib/mingle_macro_models/property_definition.rb
Overview
This is a lightweight representation of a ProjectDefinition in Mingle
Constant Summary collapse
- MANAGED_TEXT_TYPE =
"Managed text list"
- ANY_TEXT_TYPE =
"Any text"
- MANAGED_NUMBER_TYPE =
"Managed number list"
- ANY_NUMBER_TYPE =
"Any number"
- DATE_TYPE =
"Date"
- FORMULA_TYPE =
"Formula"
- USER_TYPE =
"Automatically generated from the team list"
- CARD_TYPE =
"Card"
- AGGREGATE_TYPE =
"Aggregate"
- TREE_RELATIONSHIP_TYPE =
"Any card used in tree"
Instance Attribute Summary collapse
-
#card_types_property_definitions_loader ⇒ Object
writeonly
Sets the attribute card_types_property_definitions_loader.
-
#values_loader ⇒ Object
writeonly
Sets the attribute values_loader.
Instance Method Summary collapse
-
#calculated? ⇒ Boolean
returns: True if a property definition has only calculated values, such as ones of Formula & Aggregate types.
-
#card_types ⇒ Object
returns: A list of CardTypes that this PropertyDefinition is valid for.
-
#date? ⇒ Boolean
returns: True if a property definition has only numeric values, such as the Date type.
-
#description ⇒ Object
returns: The description of this PropertyDefinition.
-
#initialize(full_property_definition) ⇒ PropertyDefinition
constructor
A new instance of PropertyDefinition.
-
#name ⇒ Object
returns: The name of this PropertyDefinition.
-
#numeric? ⇒ Boolean
returns: True if a property definition has only numeric values, such as ones of Un/managed number types.
-
#textual? ⇒ Boolean
returns: True if a property definition has only textual values, such as ones of Un/managed text types.
- #to_s ⇒ Object
-
#type_description ⇒ Object
returns: A short description of the property definition.
-
#values ⇒ Object
returns: A list of explicitly defined values that this PropertyDefinition has This method should ONLY be called for property definitions that are of the following types - MANAGED_TEXT_TYPE - MANAGED_NUMBER_TYPE - USER_TYPE.
Constructor Details
#initialize(full_property_definition) ⇒ PropertyDefinition
Returns a new instance of PropertyDefinition.
18 19 20 |
# File 'lib/mingle_macro_models/property_definition.rb', line 18 def initialize(full_property_definition) @full_property_definition = full_property_definition end |
Instance Attribute Details
#card_types_property_definitions_loader=(value) ⇒ Object (writeonly)
Sets the attribute card_types_property_definitions_loader
102 103 104 |
# File 'lib/mingle_macro_models/property_definition.rb', line 102 def card_types_property_definitions_loader=(value) @card_types_property_definitions_loader = value end |
#values_loader=(value) ⇒ Object (writeonly)
Sets the attribute values_loader
102 103 104 |
# File 'lib/mingle_macro_models/property_definition.rb', line 102 def values_loader=(value) @values_loader = value end |
Instance Method Details
#calculated? ⇒ Boolean
returns: True if a property definition has only calculated values, such as ones of Formula & Aggregate types
89 90 91 |
# File 'lib/mingle_macro_models/property_definition.rb', line 89 def calculated? type_description == FORMULA_TYPE || type_description == AGGREGATE_TYPE end |
#card_types ⇒ Object
returns: A list of CardTypes that this PropertyDefinition is valid for
33 34 35 |
# File 'lib/mingle_macro_models/property_definition.rb', line 33 def card_types @card_types_property_definitions_loader.load.collect(&:card_type).sort_by(&:position) end |
#date? ⇒ Boolean
returns: True if a property definition has only numeric values, such as the Date type
94 95 96 |
# File 'lib/mingle_macro_models/property_definition.rb', line 94 def date? type_description == DATE_TYPE end |
#description ⇒ Object
returns: The description of this PropertyDefinition
28 29 30 |
# File 'lib/mingle_macro_models/property_definition.rb', line 28 def description @full_property_definition.description end |
#name ⇒ Object
returns: The name of this PropertyDefinition
23 24 25 |
# File 'lib/mingle_macro_models/property_definition.rb', line 23 def name @full_property_definition.name end |
#numeric? ⇒ Boolean
returns: True if a property definition has only numeric values, such as ones of Un/managed number types
84 85 86 |
# File 'lib/mingle_macro_models/property_definition.rb', line 84 def numeric? type_description == MANAGED_NUMBER_TYPE || type_description == ANY_NUMBER_TYPE end |
#textual? ⇒ Boolean
returns: True if a property definition has only textual values, such as ones of Un/managed text types
79 80 81 |
# File 'lib/mingle_macro_models/property_definition.rb', line 79 def textual? type_description == MANAGED_TEXT_TYPE || type_description == ANY_TEXT_TYPE end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/mingle_macro_models/property_definition.rb', line 98 def to_s "PropertyDefinition[name=#{name},type=#{type}]" end |
#type_description ⇒ Object
returns: A short description of the property definition. This will be one of the above values
-
MANAGED_TEXT_TYPE
-
ANY_TEXT_TYPE
-
MANAGED_NUMBER_TYPE
-
ANY_NUMBER_TYPE
-
DATE_TYPE
-
FORMULA_TYPE
-
USER_TYPE
-
CARD_TYPE
-
AGGREGATE_TYPE
-
TREE_RELATIONSHIP_TYPE
49 50 51 |
# File 'lib/mingle_macro_models/property_definition.rb', line 49 def type_description @full_property_definition.type_description end |
#values ⇒ Object
returns: A list of explicitly defined values that this PropertyDefinition has This method should ONLY be called for property definitions that are of the following types
-
MANAGED_TEXT_TYPE
-
MANAGED_NUMBER_TYPE
-
USER_TYPE
Attempting to call this method for the following types will throw an Exception
-
ANY_TEXT_TYPE
-
ANY_NUMBER_TYPE
-
FORMULA_TYPE
-
AGGREGATE_TYPE
-
CARD_TYPE
-
TREE_RELATIONSHIP_TYPE
-
DATE_TYPE
To get the values for the above types, you can use MQL, such as “SELECT property_name” to get a list of values
70 71 72 73 74 75 76 |
# File 'lib/mingle_macro_models/property_definition.rb', line 70 def values valid_property_types_to_call_value_on = [MANAGED_TEXT_TYPE, MANAGED_NUMBER_TYPE, USER_TYPE] unless valid_property_types_to_call_value_on.any? {|t| self.type_description == t} raise "Do not call this method for property definitions of types other than MANAGED_TEXT_TYPE, MANAGED_NUMBER_TYPE, USER_TYPE." end @values_loader.load end |