Module: Serega::SeregaPlugins::Formatters::AttributeInstanceMethods

Defined in:
lib/serega/plugins/formatters/formatters.rb

Overview

Attribute class additional/patched instance methods

Instance Method Summary collapse

Instance Method Details

#formatter#call

Returns callable formatter.

Returns:

  • (#call)

    callable formatter



134
135
136
137
138
# File 'lib/serega/plugins/formatters/formatters.rb', line 134

def formatter
  return @formatter if instance_variable_defined?(:@formatter)

  @formatter = formatter_resolved
end

#value_block#call

Returns callable, that should be used to fetch attribute value.

Returns:

  • (#call)

    callable, that should be used to fetch attribute value



141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/serega/plugins/formatters/formatters.rb', line 141

def value_block
  return @value_block if instance_variable_defined?(:@value_block)
  return @value_block = super unless formatter

  new_value_block = formatted_block(formatter, super)

  # Format :const value in advance
  if opts.key?(:const)
    const_value = new_value_block.call
    new_value_block = proc { const_value }
  end

  @value_block = new_value_block
end