Class: Udb::Portfolio::InScopeParameter
- Inherits:
-
Object
- Object
- Udb::Portfolio::InScopeParameter
- Defined in:
- lib/udb/obj/portfolio.rb
Overview
InScopeParameter Class #
Instance Attribute Summary collapse
-
#note ⇒ String
readonly
Optional note associated with the parameter.
-
#param ⇒ Parameter
readonly
Parameter object (from the architecture database).
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
sorts by name.
-
#allowed_values ⇒ String
-
# What parameter values are allowed by the portfolio.
-
- #idl_type ⇒ Object
-
#initialize(param, schema_hash, note) ⇒ InScopeParameter
constructor
A new instance of InScopeParameter.
- #name ⇒ Object
- #single_value? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(param, schema_hash, note) ⇒ InScopeParameter
Returns a new instance of InScopeParameter.
722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/udb/obj/portfolio.rb', line 722 def initialize(param, schema_hash, note) raise ArgumentError, "Expecting Parameter" unless param.is_a?(Parameter) if schema_hash.nil? schema_hash = {} else raise ArgumentError, "Expecting schema_hash to be a hash" unless schema_hash.is_a?(Hash) end @param = param @schema_portfolio = Schema.new(schema_hash) @note = note end |
Instance Attribute Details
#note ⇒ String (readonly)
Returns Optional note associated with the parameter.
720 721 722 |
# File 'lib/udb/obj/portfolio.rb', line 720 def note @note end |
#param ⇒ Parameter (readonly)
Returns Parameter object (from the architecture database).
717 718 719 |
# File 'lib/udb/obj/portfolio.rb', line 717 def param @param end |
Instance Method Details
#<=>(other) ⇒ Object
sorts by name
762 763 764 765 766 |
# File 'lib/udb/obj/portfolio.rb', line 762 def <=>(other) raise ArgumentError, "InScopeParameter are only comparable to other parameter constraints" unless other.is_a?(InScopeParameter) @param.name <=> other.param.name end |
#allowed_values ⇒ String
Returns - # What parameter values are allowed by the portfolio.
747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File 'lib/udb/obj/portfolio.rb', line 747 def allowed_values if (@schema_portfolio.empty?) # Portfolio doesn't add any constraints on parameter's value. return "Any" end # Create a Schema object just using information in the parameter database. schema_obj = @param.schema # Merge in constraints imposed by the portfolio on the parameter and then # create string showing allowed values of parameter with portfolio constraints added. schema_obj.merge(@schema_portfolio).to_pretty_s end |
#idl_type ⇒ Object
737 |
# File 'lib/udb/obj/portfolio.rb', line 737 def idl_type = @param.type |
#name ⇒ Object
736 |
# File 'lib/udb/obj/portfolio.rb', line 736 def name = @param.name |
#single_value? ⇒ Boolean
738 |
# File 'lib/udb/obj/portfolio.rb', line 738 def single_value? = @schema_portfolio.single_value? |
#value ⇒ Object
740 741 742 743 744 |
# File 'lib/udb/obj/portfolio.rb', line 740 def value raise "Parameter schema_portfolio for #{name} is not a single value" unless single_value? @schema_portfolio.value end |