lib/redd/objects/subreddit.rb in redd-0.7.5 vs lib/redd/objects/subreddit.rb in redd-0.7.6

- old
+ new

@@ -39,11 +39,11 @@ params = { extension: "json", title: title, sr: display_name, resubmit: resubmit, sendreplies: sendreplies } - params << {captcha: captcha, iden: identifier} if captcha + params.merge!(captcha: captcha, iden: identifier) if captcha params[:kind], params[:text] = :self, text if text params[:kind], params[:url] = :link, url if url response = post("/api/submit", params) Objects::Thing.new(self, response.body[:json][:data]) @@ -148,19 +148,20 @@ # set the flair to. # @param [:user, :link] type The type of thing. # @param [String] text The text to set the flair to. # @param [String] css_class The css_class of the flair. def set_flair(thing, type = nil, text = nil, css_class = nil) + params = {text: text, css_class: css_class} if thing.is_a?(Objects::User) || type == :user params[:name] = client.property(thing, :name) - elsif thing.is_a?(Objects::Submission) || type == :user + elsif thing.is_a?(Objects::Submission) || type == :link params[:link] = client.property(thing, :fullname) else fail "You should provide a proper type." end - post("/r/#{display_name}/api/flair", text: text, css_class: css_class) + post("/r/#{display_name}/api/flair", params) end # @!endgroup # @!group Listings @@ -280,19 +281,19 @@ if required.all? { |key| attributes.key?(key) } params.merge!(attributes) else about = admin_about final = about - .select { |k, _| required.include?(k) } - .merge( - name: display_name, - type: about[:subreddit_type], - lang: about[:language], - link_type: about[:content_options], - allow_top: true, - css_on_cname: true - ) - .merge(attributes) + .select { |k, _| required.include?(k) } + .merge( + name: display_name, + type: about[:subreddit_type], + lang: about[:language], + link_type: about[:content_options], + allow_top: true, + css_on_cname: true + ) + .merge(attributes) params.merge!(final) end post("/api/site_admin", params) end