Sha256: 025b6e139e66396559448d6798087b58851ffc6f4764faa04e3bf36bcc26dd68

Contents?: true

Size: 866 Bytes

Versions: 2

Compression:

Stored size: 866 Bytes

Contents

module Clever
  # District resource
  class District < APIResource
    include Clever::APIOperations::List
    @linked_resources = [:schools, :teachers, :sections, :students, :events]

    # @see Clever::CleverObject.optional_attributes
    # @api private
    # @return [Array]
    def optional_attributes
      # All of a district's attributes are required.
      []
    end

    # TODO: remove
    [:school_pages, :teacher_pages, :section_pages, :student_pages, :event_pages].each do |name|
      define_method(name) do |filters = {}|
        Clever::APIOperations::PageList.new get_uri(name.to_s.gsub('_page', '')), filters
      end
    end

    private

    # Get the URI for a hypermedia link
    # @api private
    # @return [String]
    def get_uri(resource_type)
      refresh
      links.find { |link| link[:rel] == resource_type }[:uri]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clever-ruby-0.6.2 lib/clever-ruby/district.rb
clever-ruby-0.6.1 lib/clever-ruby/district.rb