Class: Traitify::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Model, Overrides, Request, Setup, Configuration
Defined in:
lib/traitify/client.rb,
lib/traitify/client/model.rb,
lib/traitify/client/setup.rb,
lib/traitify/client/request.rb,
lib/traitify/client/overrides.rb,
lib/traitify/client/connection.rb

Defined Under Namespace

Modules: Connection, Model, Overrides, Request, Setup

Constant Summary

Constants included from Configuration

Traitify::Configuration::VALID_OPTIONS_KEYS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Setup

#add_params, #add_path, #set, #set_param

Methods included from Request

#data, #request, #retriable

Methods included from Overrides

#assessments_override, #locales_override, #perform_overrides, #personality_types_override

Methods included from Model

#base, #create, #destroy, #find, #update

Methods included from Connection

#connection

Methods included from Configuration

#configure, #options

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
# File 'lib/traitify/client.rb', line 9

def initialize(options = {})
  Traitify.options.merge(options).each do |key, value|
    send("#{key}=", value) unless value.nil?
  end

  set(verb: :get, path: "", params: {})
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



17
18
19
# File 'lib/traitify/client.rb', line 17

def method_missing(method_name, *args, &block)
  base(method_name, *args)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



7
8
9
# File 'lib/traitify/client.rb', line 7

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/traitify/client.rb', line 7

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/traitify/client.rb', line 7

def type
  @type
end

#verbObject (readonly)

Returns the value of attribute verb.



7
8
9
# File 'lib/traitify/client.rb', line 7

def verb
  @verb
end

Instance Method Details

#to_hashObject Also known as: to_h



21
22
23
# File 'lib/traitify/client.rb', line 21

def to_hash
  Hash[instance_variables.collect{ |key| [key.to_s.delete("@"), instance_variable_get(key)] }]
end