Class: Castle::Context::GetDefault

Inherits:
Object
  • Object
show all
Defined in:
lib/castle/context/get_default.rb

Instance Method Summary collapse

Constructor Details

#initialize(request, cookies = nil) ⇒ GetDefault

Returns a new instance of GetDefault.



6
7
8
9
10
# File 'lib/castle/context/get_default.rb', line 6

def initialize(request, cookies = nil)
  @pre_headers = Castle::Headers::Filter.new(request).call
  @cookies = cookies || request.cookies
  @request = request
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/castle/context/get_default.rb', line 12

def call
  {
    client_id: client_id,
    active: true,
    headers: headers,
    ip: ip,
    library: {
      name: 'castle-rb',
      version: Castle::VERSION
    }
  }.tap do |result|
    result[:locale] = locale if locale
    result[:user_agent] = user_agent if user_agent
  end
end