# File lib/deltacloud/models/hardware_profile.rb, line 50 def initialize(profile_id, &block) @properties = {} super(:id => profile_id) result = instance_eval(&block) if block_given? @name ||= profile_id result end
# File lib/deltacloud/models/hardware_profile.rb, line 32 def property(prop) define_method(prop) do |*args| values, opts, *ignored = *args unless values.nil? @properties[prop] = Property.new(prop, values, opts || {}) end @properties[prop] end end
# File lib/deltacloud/models/hardware_profile.rb, line 27 def self.unit(name) UNITS[name] end
# File lib/deltacloud/models/hardware_profile.rb, line 70 def default?(prop, v) property(prop) && property(prop).default.to_s == v end
# File lib/deltacloud/models/hardware_profile.rb, line 58 def each_property(&block) @properties.each_value { |prop| yield prop } end
# File lib/deltacloud/models/hardware_profile.rb, line 74 def include?(prop, v) return false unless p = property(prop) return true if p.kind == :range and (p.first..p.last).include?(v) return true if p.kind == :enum and p.values.include?(v) false end
# File lib/deltacloud/models/hardware_profile.rb, line 81 def params @properties.values.inject([]) { |m, prop| m << prop.to_param }.compact end
# File lib/deltacloud/models/hardware_profile.rb, line 62 def properties @properties.values end
# File lib/deltacloud/models/hardware_profile.rb, line 66 def property(name) @properties[name.to_sym] end