Module: Hanami::Action::Exposable

Defined in:
lib/hanami/action/exposable.rb,
lib/hanami/action/exposable/guard.rb

Overview

Exposures API

See Also:

Since:

  • 0.1.0

Defined Under Namespace

Modules: ClassMethods, Guard

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ 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.

Override Ruby's hook for modules. It includes exposures logic

Parameters:

  • base (Class)

    the target action

See Also:

Since:

  • 0.1.0


20
21
22
23
24
25
26
27
# File 'lib/hanami/action/exposable.rb', line 20

def self.included(base)
  base.class_eval do
    extend ClassMethods
    include Guard

    _expose :params
  end
end

Instance Method Details

#exposuresHash

Set of exposures

Returns:

  • (Hash)

    the exposures

See Also:

  • Hanami::Action::Exposable::ClassMethods.expose

Since:

  • 0.1.0


106
107
108
109
110
111
112
# File 'lib/hanami/action/exposable.rb', line 106

def exposures
  @exposures ||= {}.tap do |result|
    self.class.exposures.each do |name|
      result[name] = send(name)
    end
  end
end

#finishObject

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.

Finalize the response

See Also:

  • Hanami::Action#finish

Since:

  • 0.3.0


120
121
122
123
# File 'lib/hanami/action/exposable.rb', line 120

def finish
  super
  exposures
end