Class: Spaceship::TestFlight::Base

Inherits:
Base
  • Object
show all
Defined in:
spaceship/lib/spaceship/test_flight/base.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s

Constructor Details

This class inherits a constructor from Spaceship::Base

Class Method Details

.clientObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'spaceship/lib/spaceship/test_flight/base.rb', line 7

def self.client
  # Verify there is a client that can be used
  if Spaceship::Tunes.client
    # Initialize new client if new or if team changed
    if @client.nil? || @client.team_id != Spaceship::Tunes.client.team_id
      @client = Client.client_with_authorization_from(Spaceship::Tunes.client)
    end
  end

  # Need to handle not having a client but this shouldn't ever happen
  raise "Please login using `Spaceship::Tunes.login('user', 'password')`" unless @client

  @client
end

.inherited(subclass) ⇒ Object

Have subclasses inherit the client from their superclass

Essentially, we are making a class-inheritable-accessor as described here: apidock.com/rails/v4.2.7/Class/class_attribute



27
28
29
30
31
32
# File 'spaceship/lib/spaceship/test_flight/base.rb', line 27

def self.inherited(subclass)
  this_class = self
  subclass.define_singleton_method(:client) do
    this_class.client
  end
end

Instance Method Details

#to_jsonObject



34
35
36
# File 'spaceship/lib/spaceship/test_flight/base.rb', line 34

def to_json
  raw_data.to_json
end