lib/apipie/validator.rb in apipie-rails-0.1.2 vs lib/apipie/validator.rb in apipie-rails-0.1.3

- old
+ new

@@ -68,10 +68,14 @@ def merge_with(other_validator) raise NotImplementedError, "Dont know how to merge #{self.inspect} with #{other_validator.inspect}" end + def params_ordered + nil + end + end # validate arguments type class TypeValidator < BaseValidator @@ -216,12 +220,12 @@ param_description.required = true end prepare_hash_params end - def hash_params_ordered - @hash_params_ordered ||= _apipie_dsl_data[:params].map do |args| + def params_ordered + @params_ordered ||= _apipie_dsl_data[:params].map do |args| options = args.find { |arg| arg.is_a? Hash } options[:parent] = self.param_description Apipie::ParamDescription.from_dsl_data(param_description.method_description, args) end end @@ -265,19 +269,19 @@ @param_group && @param_group[:scope] end def merge_with(other_validator) if other_validator.is_a? HashValidator - @hash_params_ordered = ParamDescription.unify(self.hash_params_ordered + other_validator.hash_params_ordered) + @params_ordered = ParamDescription.unify(self.params_ordered + other_validator.params_ordered) prepare_hash_params else super end end def prepare_hash_params - @hash_params = hash_params_ordered.reduce({}) do |h, param| + @hash_params = params_ordered.reduce({}) do |h, param| h.update(param.name.to_sym => param) end end end @@ -370,9 +374,13 @@ self.new(param_description, block, options[:param_group]) if block.is_a?(Proc) && block.arity <= 0 && argument == Array end def description "Must be an Array of nested elements" + end + + def params_ordered + @validator.params_ordered end end end end