nack - sorry mate logic error inline (though may also be ruby version related - I am on 1.8.7):
On 17/01/12 13:52, [email protected] wrote: > From: Michal Fojtik <[email protected]> > > <snip> > private > diff --git a/server/lib/cimi/model/entity_metadata.rb > b/server/lib/cimi/model/entity_metadata.rb > index 2611873..922df1f 100644 > --- a/server/lib/cimi/model/entity_metadata.rb > +++ b/server/lib/cimi/model/entity_metadata.rb > @@ -63,14 +63,14 @@ text :type_uri > private > > def self.attributes_from_feature(feature) > - attributes = [] > - feature.operations.first.params.each_key do |param| > - attributes << { > + feature.operations.first.params.inject([]) do |result, param| here, feature.operations.first.params is a hash, for example: { :hwp_cpu=>#<Deltacloud::Validation::Param:0xb71d7f10 @name=:hwp_cpu, @description="", @options=[], @type=:optional, @klass=:string>, :hwp_memory=>#<Deltacloud::Validation::Param:0xb71d7e84 @name=:hwp_memory, @description="", @options=[], @type=:optional, @klass=:string>, ... etc } which means that for each iteration of "inject", you are using the whole 'hash=>key'; for 1.8.7 this produces an array of length 2... i.e. param is something like: [:hwp_cpu, #<Deltacloud::Validation::Param:0xb71d7f10 @name=:hwp_cpu, @description="", @options=[], @type=:optional, @klass=:string>] this means that: > + p = feature.operations.first.params[param] > + result << { > :name=>(feature.name == :user_name ? :name : param), name is set to the array and > :type=> "xs:string", > - :required=>(feature.operations.first.params[param].type == :optional > ? "false" : "true"), > + :required=> (p and p.optional?) ? "false" : "true", this is always "true" For me the fix was to treat param as a hash by seperating key=>value in the inject: feature.operations.first.params.inject([]) do |result, (param, values)| and everything else should be sound > :constraints=> (feature.constraints.empty? ? > (feature.description.nil? ? "" : feature.description): feature.constraints) > - } > + } > end > attributes > end
