Module: Hanami::Extensions::View::Context::InstanceMethods Private

Defined in:
lib/hanami/extensions/view/context.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#assetsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



50
51
52
53
54
55
56
# File 'lib/hanami/extensions/view/context.rb', line 50

def assets
  unless _options[:assets]
    raise Hanami::ComponentLoadError, "hanami-assets gem is required to access assets"
  end

  _options[:assets]
end

#content_for(key, value = nil, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/hanami/extensions/view/context.rb', line 58

def content_for(key, value = nil, &block)
  content = _options[:content]
  output = nil

  if block
    content[key] = yield
  elsif value
    content[key] = value
  else
    output = content[key]
  end

  output
end

#csrf_tokenObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



77
78
79
# File 'lib/hanami/extensions/view/context.rb', line 77

def csrf_token
  request.session[Hanami::Action::CSRFProtection::CSRF_TOKEN]
end

#current_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



73
74
75
# File 'lib/hanami/extensions/view/context.rb', line 73

def current_path
  request.fullpath
end

#flashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



89
90
91
# File 'lib/hanami/extensions/view/context.rb', line 89

def flash
  response.flash
end

#inflectorObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



38
39
40
# File 'lib/hanami/extensions/view/context.rb', line 38

def inflector
  _options.fetch(:inflector)
end

#initialize(**kwargs) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:

  • SliceConfiguredContext#define_new

Since:

  • 0.1.0



32
33
34
35
36
# File 'lib/hanami/extensions/view/context.rb', line 32

def initialize(**kwargs)
  defaults = {content: {}}

  super(**kwargs, **defaults)
end

#requestObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



81
82
83
# File 'lib/hanami/extensions/view/context.rb', line 81

def request
  _options.fetch(:request)
end

#routesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



42
43
44
# File 'lib/hanami/extensions/view/context.rb', line 42

def routes
  _options.fetch(:routes)
end

#sessionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



85
86
87
# File 'lib/hanami/extensions/view/context.rb', line 85

def session
  request.session
end

#settingsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



46
47
48
# File 'lib/hanami/extensions/view/context.rb', line 46

def settings
  _options.fetch(:settings)
end