Class: Flox::Player

Inherits:
Entity
  • Object
show all
Defined in:
lib/flox/player.rb

Overview

An Entity that contains information about a Flox Player. Normally, you don't create instances of Player yourself. There's always a player logged in you can access with

flox.current_player # => Flox::Player

To log in as a different player, you'll probably want to use a key-login. When you use the Flox Gem as a maintenance tool, create a "Hero" in the online interface and use its key to login. That way, you have access to all entities, regardless of their public_access values.

flox. 'hero-key' # => Flox::Player

The Player class itself is just an entity that adds an auth_type property for your convenience.

Instance Attribute Summary collapse

Attributes inherited from Entity

#created_at, #id, #owner_id, #path, #public_access, #type, #updated_at

Instance Method Summary collapse

Methods inherited from Entity

#[], #[]=, #inspect

Constructor Details

#initialize(id = nil, data = nil) ⇒ Player

Creates a player with a certain ID and data. The type of a player is always .player in Flox.



24
25
26
27
28
29
30
# File 'lib/flox/player.rb', line 24

def initialize(id=nil, data=nil)
  data ||= {}
  data[:authType] ||= "guest"
  data[:publicAccess] ||= "r"
  super(".player", id, data)
  self.owner_id ||= self.id
end

Instance Attribute Details

#auth_typeString

Returns the type of authentication the player used to log in.

Returns:

  • (String)

    the type of authentication the player used to log in.



40
41
42
# File 'lib/flox/player.rb', line 40

def auth_type
  self[:authType].to_sym
end