Class: Hanami::Helpers::FormHelper::Values Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/helpers/form_helper/values.rb

Overview

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

Values from params and form helpers.

It’s responsible to populate input values with data coming from params and inline values specified via form helpers like ‘text_field`.

Since:

  • 2.1.0

Constant Summary collapse

GET_SEPARATOR =

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

Since:

  • 2.1.0

"."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values: {}, params: {}, csrf_token: nil) ⇒ Values

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.

Returns a new instance of Values.

Since:

  • 2.1.0



24
25
26
27
28
# File 'lib/hanami/helpers/form_helper/values.rb', line 24

def initialize(values: {}, params: {}, csrf_token: nil)
  @values = values.to_h
  @params = params.to_h
  @csrf_token = csrf_token
end

Instance Attribute Details

#csrf_tokenObject (readonly)

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:

  • 2.1.0



20
21
22
# File 'lib/hanami/helpers/form_helper/values.rb', line 20

def csrf_token
  @csrf_token
end

Instance Method Details

#get(*keys) ⇒ 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.

Returns the value (if present) for the given key. Nested values are expressed with an array if symbols.

Since:

  • 2.1.0



35
36
37
# File 'lib/hanami/helpers/form_helper/values.rb', line 35

def get(*keys)
  get_from_params(*keys) || get_from_values(*keys)
end