Class: Tickethub::App

Inherits:
Resource show all
Defined in:
lib/tickethub/app.rb

Direct Known Subclasses

User::App

Defined Under Namespace

Classes: Category, Subscription

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, all, association, attribute, attributes, collection, collection_method, collection_methods, descendants, #destroy, dump_value, #eql?, #errors, #hash, inherited, #inspect, load, #load, load_value, path, polymorphic, register_type, registered_types, #reload!, #respond_to?, scope, scopes, serialize, singleton?, #to_h, #to_param, #to_s, #update, #valid?

Constructor Details

#initialize(endpoint, attributes = nil) ⇒ App

Returns a new instance of App.



23
24
25
26
27
28
29
30
31
32
# File 'lib/tickethub/app.rb', line 23

def initialize(endpoint, attributes = nil)
  attributes ||= endpoint.get

  if attributes['token']
    endpoint = Tickethub.endpoint(auth_type: :bearer,
      password: attributes['token']['access_token'])[self.class.path]
  end

  super(endpoint, attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tickethub::Resource

Class Method Details

.[](attributes) ⇒ Object



17
18
19
20
21
# File 'lib/tickethub/app.rb', line 17

def self.[](attributes)
  token = attributes[:token].is_a?(String) ? attributes[:token]
    : attributes[:token][:access_token]
  self.new Tickethub.endpoint(auth_type: :bearer, password: token)['/app']
end