Sha256: 080b5fdda38f354e1262343a18e55101ca2d26fd3b3feaf376b64771873af1bf

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

class Muddyit::Sites < Muddyit::Base

  # create a new sites object
  # not a muddyit:generic as it doesn't need the method missing loader
  #
  # Params :
  #
  # * muddyit (Required)
  # a muddyit::base instance
  #
  def initialize(muddyit)
    @muddyit = muddyit
  end

  # find a specific site
  #
  # Params
  # * type (Required)
  #   one of :all or a site token
  #
  def find(type, options = {})
    raise 'no type specified' unless type

    if type.is_a? Symbol
      case type
      when :all
        api_url = "/sites/"
        response = @muddyit.send_request(api_url, :get, options)
        sites = []
        response.each { |site| sites.push Muddyit::Sites::Site.new(@muddyit, site['site']) }
        return sites
      else
        raise 'invalid type specified'
      end
    elsif type.is_a? String
      api_url = "/sites/#{type}"
      response = @muddyit.send_request(api_url, :get, options)
      return Muddyit::Sites::Site.new(@muddyit, response['site'])
    else
      raise 'invalid type specified'
    end

  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
monkeyhelper-muddyit_fu-0.1.1 lib/muddyit/sites.rb
monkeyhelper-muddyit_fu-0.2.0 lib/muddyit/sites.rb
monkeyhelper-muddyit_fu-0.2.1 lib/muddyit/sites.rb
monkeyhelper-muddyit_fu-0.2.2 lib/muddyit/sites.rb
monkeyhelper-muddyit_fu-0.2.3 lib/muddyit/sites.rb
monkeyhelper-muddyit_fu-0.2.4 lib/muddyit/sites.rb
muddyit_fu-0.2.8 lib/muddyit/sites.rb
muddyit_fu-0.2.6 lib/muddyit/sites.rb