Class: ActiveShotgun::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/active_shotgun/client.rb

Constant Summary collapse

CONNECTION_TYPES =
["multi_entity", "entity"].freeze
READ_ONLY_TYPES =
["image", "summary"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



14
15
16
17
18
19
# File 'lib/active_shotgun/client.rb', line 14

def initialize
  @shotgun = ShotgunApiRuby.new(
    shotgun_site: Config.shotgun_site_name || Config.shotgun_site_url,
    auth: { client_id: Config.shotgun_client_id, client_secret: Config.shotgun_client_secret }
  )
end

Instance Attribute Details

#shotgunObject (readonly)

Returns the value of attribute shotgun.



20
21
22
# File 'lib/active_shotgun/client.rb', line 20

def shotgun
  @shotgun
end

Instance Method Details

#fetch_field_names_for_an_entity_type(type) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/active_shotgun/client.rb', line 32

def fetch_field_names_for_an_entity_type(type)
  result = shotgun.entities(type).fields.to_h
  {
    writable: result.reject do |_, v|
      (CONNECTION_TYPES + READ_ONLY_TYPES).include?(v.data_type) ||
        !v.editable
    end.keys,
    readable: result.reject{ |_, v| CONNECTION_TYPES.include?(v.data_type) }.keys,
  }
end