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.
894 895 896 897 898 899 900 901 902 903 904 905 906 |
# File 'lib/udb/obj/portfolio.rb', line 894 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.
892 893 894 |
# File 'lib/udb/obj/portfolio.rb', line 892 def note @note end |
#param ⇒ Parameter (readonly)
Returns Parameter object (from the architecture database).
889 890 891 |
# File 'lib/udb/obj/portfolio.rb', line 889 def param @param end |
Instance Method Details
#<=>(other) ⇒ Object
sorts by name
934 935 936 937 938 |
# File 'lib/udb/obj/portfolio.rb', line 934 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.
919 920 921 922 923 924 925 926 927 928 929 930 931 |
# File 'lib/udb/obj/portfolio.rb', line 919 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
909 |
# File 'lib/udb/obj/portfolio.rb', line 909 def idl_type = @param.type |
#name ⇒ Object
908 |
# File 'lib/udb/obj/portfolio.rb', line 908 def name = @param.name |
#single_value? ⇒ Boolean
910 |
# File 'lib/udb/obj/portfolio.rb', line 910 def single_value? = @schema_portfolio.single_value? |
#value ⇒ Object
912 913 914 915 916 |
# File 'lib/udb/obj/portfolio.rb', line 912 def value raise "Parameter schema_portfolio for #{name} is not a single value" unless single_value? @schema_portfolio.value end |