module Ecoportal module API class V2 class Page class Component class PlainTextField < Page::Component passthrough :value passboolean :multiline passthrough :max_length passboolean :exact_index # Quick config helper # @param conf [Symbol, Array] # - `: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` 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 end end end end end end