Sha256: dee37220927f00b18c8f4b944e61ee52ddcf80e0d7907c3c9d18fcc7bd3c0481

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

module Clever
  # Event resource
  class Event < APIResource
    include Clever::APIOperations::List

    # Optional attributes
    # @see Clever::CleverObject.optional_attributes
    # @api private
    # @return [Array]
    def optional_attributes
      []
    end

    # Get object corresponding to this event
    # @api public
    # @return [CleverObject]
    # @example
    #   district = event.object
    def object
      klass = APIResource.named type_pieces[0]
      klass ||= CleverObject
      klass.construct_from data[:object]
    end

    # Get previous attributes before the event
    # @api public
    # @return [Hash]
    # @example
    #   prev = event.previous_attributes
    def previous_attributes
      data[:previous_attributes]
    end

    # Get action taken in Event
    # @api public
    # @return [String]
    # @example
    #   action = event.action
    def action
      type_pieces[1]
    end

    # Get URL for events endpoint
    # @api private
    # @return [String]
    def self.url
      'v1.1/events'
    end

    private

    # Split type of Event into pieces
    # @api private
    # @return [Array]
    def type_pieces
      type.split '.'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
clever-ruby-0.11.1 lib/clever-ruby/event.rb
clever-ruby-0.11.0 lib/clever-ruby/event.rb
clever-ruby-0.10.2 lib/clever-ruby/event.rb
clever-ruby-0.10.1 lib/clever-ruby/event.rb
clever-ruby-0.10.0 lib/clever-ruby/event.rb
clever-ruby-0.9.0 lib/clever-ruby/event.rb
clever-ruby-0.8.0 lib/clever-ruby/event.rb
clever-ruby-0.7.0 lib/clever-ruby/event.rb