Sha256: 788756d6f412c05b570c60819f5bd7455b6302d24a7c15288dabe40f723ddc5a

Contents?: true

Size: 1.77 KB

Versions: 26

Compression:

Stored size: 1.77 KB

Contents

module Ecoportal
  module API
    class V2
      class Page
        class Component
          class PlainTextField < Page::Component
            passthrough :value
            passboolean :multiline
            passthrough :max_length
            passboolean :exact_index

            def empty?
              value.to_s.strip.empty?
            end
            
            def to_s
              value
            end

            # 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`
            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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ecoportal-api-v2-2.0.12 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.11 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.10 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.9 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.8 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.7 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.6 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.5 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.4 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.3 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.2 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.1 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-2.0.0 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-1.1.8 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-1.1.7 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-1.1.6 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-1.1.5 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-1.1.4 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-1.1.3 lib/ecoportal/api/v2/page/component/plain_text_field.rb
ecoportal-api-v2-1.1.2 lib/ecoportal/api/v2/page/component/plain_text_field.rb