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.
839 840 841 842 843 844 845 846 847 848 849 850 851 |
# File 'lib/udb/obj/portfolio.rb', line 839 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.
837 838 839 |
# File 'lib/udb/obj/portfolio.rb', line 837 def note @note end |
#param ⇒ Parameter (readonly)
Returns Parameter object (from the architecture database).
834 835 836 |
# File 'lib/udb/obj/portfolio.rb', line 834 def param @param end |
Instance Method Details
#<=>(other) ⇒ Object
sorts by name
879 880 881 882 883 |
# File 'lib/udb/obj/portfolio.rb', line 879 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.
864 865 866 867 868 869 870 871 872 873 874 875 876 |
# File 'lib/udb/obj/portfolio.rb', line 864 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
854 |
# File 'lib/udb/obj/portfolio.rb', line 854 def idl_type = @param.type |
#name ⇒ Object
853 |
# File 'lib/udb/obj/portfolio.rb', line 853 def name = @param.name |
#single_value? ⇒ Boolean
855 |
# File 'lib/udb/obj/portfolio.rb', line 855 def single_value? = @schema_portfolio.single_value? |
#value ⇒ Object
857 858 859 860 861 |
# File 'lib/udb/obj/portfolio.rb', line 857 def value raise "Parameter schema_portfolio for #{name} is not a single value" unless single_value? @schema_portfolio.value end |