lib/redd/models/wiki_page.rb in redd-0.8.1 vs lib/redd/models/wiki_page.rb in redd-0.8.2

- old
+ new

@@ -4,21 +4,18 @@ module Redd module Models # A reddit user. class WikiPage < LazyModel - # Make a Wikipage from its title and subreddit. - # @option hash [String] :title the page's title - # @option hash [Subreddit] :subreddit the page's subreddit - # @return [WikiPage] - def self.from_response(client, hash) - title = hash.fetch(:title) - if hash.key?(:subreddit) - sr_name = hash[:subreddit].display_name - new(client, hash) { |c| c.get("/r/#{sr_name}/wiki/#{title}").body[:data] } - else - new(client, hash) { |c| c.get("/wiki/#{title}").body[:data] } + private + + def default_loader + title = @attributes.fetch(:title) + if @attributes.key?(:subreddit) + sr_name = attributes[:subreddit].display_name + return @client.get("/r/#{sr_name}/wiki/#{title}").body[:data] end + @client.get("/wiki/#{title}").body[:data] end end end end