lib/nytimes_articles/article.rb in harrisj-nytimes-articles-0.1.3 vs lib/nytimes_articles/article.rb in harrisj-nytimes-articles-0.2.0

- old
+ new

@@ -55,11 +55,11 @@ article = Article.new( :abstract => text_field(params['abstract']), :author => text_field(params['author']), :body => text_field(params['body']), :byline => text_field(params['byline']), - :fee => params['fee'] || false, + :fee => boolean_field(params['fee']), :lead_paragraph => text_field(params['lead_paragraph']), :nytd_title => text_field(params['nytd_title']), :nytd_lead_paragraph => text_field(params['nytd_lead_paragraph']), :related_multimedia => nil, # FIXME :thumbnail => Thumbnail.init_from_api(params), @@ -300,19 +300,15 @@ out_params['query'] = query.compact.join(' ') out_params['query'] = nil if out_params['query'].empty? end def self.facet_argument(name, value, exclude = false) - unless value.is_a? Array - value = [value] - end - if name.is_a? Symbol name = Facet.symbol_name(name) end - "#{'-' if exclude}#{name}:[#{value.join(',')}]" + "#{'-' if exclude}#{name}:[#{value}]" end def self.parse_facet_params(facets, exclude = false) facet_args = [] @@ -336,14 +332,22 @@ facet_hash[f.facet_type] << f.term end facet_hash.each_pair do |k,v| - facet_args << facet_argument(k, v, exclude) + if v.is_a? Array + facet_args += v.map {|el| facet_argument(k, el, exclude)} + else + facet_args << facet_argument(k, v, exclude) + end end when Hash facets.each_pair do |k,v| - facet_args << facet_argument(k, v, exclude) + if v.is_a? Array + facet_args += v.map {|el| facet_argument(k, el, exclude)} + else + facet_args << facet_argument(k, v, exclude) + end end end facet_args end \ No newline at end of file