Sha256: 56c141e6ad55d6e1d08e92573699a1da0b22f2c9dadca5df973d95d5b38d2dff
Contents?: true
Size: 792 Bytes
Versions: 3
Compression:
Stored size: 792 Bytes
Contents
require 'lotus/utils/hash' module Lotus module Helpers module FormHelper class Values GET_SEPARATOR = '.'.freeze def initialize(values, params) @values = Utils::Hash.new(values).stringify! @params = params end def get(key) @params.get(key) || _get_from_values(key) end private def _get_from_values(key) initial_key, *keys = key.to_s.split(GET_SEPARATOR) result = @values[initial_key] Array(keys).each do |k| break if result.nil? result = if result.respond_to?(k) result.public_send(k) else nil end end result end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lotus-helpers-0.2.6 | lib/lotus/helpers/form_helper/values.rb |
lotus-helpers-0.2.5 | lib/lotus/helpers/form_helper/values.rb |
lotus-helpers-0.2.0 | lib/lotus/helpers/form_helper/values.rb |