class Ecoportal::API::V2::Page::Component::PlainTextField

Public Instance Methods

configure(*conf) click to toggle source

Quick config helper @param conf [Symbol, Array<Symbol>]

- `:multiline` multi line mode
- `:singleline` signle line mode
- `:exact_index` to make the `value` indexed as a **whole** (as opposite to its parts or n-grams)
- `:max_length` specify the maximum length of the `value`
# File lib/ecoportal/api/v2/page/component/plain_text_field.rb, line 18
def configure(*conf)
  conf.each_with_object([]) do |cnf, unused|
    case cnf
    when :multiline
      self.multiline = true
    when :singleline
      self.multiline = false
    when :exact_index
      self.exact_index = true
    when Hash
      supported = [:multiline, :max_length]
      unless (rest = hash_except(cnf.dup, *supported)).empty?
        unused.push(rest)
      end
      if cnf.key?(:multiline)  then self.multiline = !!cnf[:multiline] end
      if cnf.key?(:max_length) then self.max_length = cnf[:max_length] end
    else
      unused.push(cnf)
    end
  end.yield_self do |unused|
    super(*unused)
  end
end