Sha256: e5376100c59dbe154492e99c06eefe231846b9d9f7e262c91306fc9cd40b57dd
Contents?: true
Size: 920 Bytes
Versions: 3
Compression:
Stored size: 920 Bytes
Contents
# frozen_string_literal: true require_relative 'lazy_model' module Redd module Models # A multi. class Multireddit < LazyModel # Make a Multireddit from its path. # @option hash [String] :path the multi's path # @return [Multireddit] def self.from_response(client, hash) path = hash.fetch(:path) new(client, hash) { |c| c.get("/api/multi#{path}").body[:data] } end # Create a Multireddit from its path. # @param client [APIClient] the api client to initialize the object with # @param id [String] the multi's path (prepended by a /) # @return [Multireddit] def self.from_id(client, id) from_response(client, path: id) end def after_initialize @attributes[:subreddits].map! do |subreddit| Subreddit.from_response(client, display_name: subreddit[:name]) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redd-0.8.0 | lib/redd/models/multireddit.rb |
redd-0.8.0.pre.2 | lib/redd/models/multireddit.rb |
redd-0.8.0.pre.1 | lib/redd/models/multireddit.rb |