class Ecoportal::API::V2::Page::Component::TagField

Public Instance Methods

configure(*conf) click to toggle source

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

- `:multiple` to allow multiple selection
- `:single` to set to singular selection
- `:default_tag` to prepopulate using users's `default_tag`
- `:button_text` to define the button description
# File lib/ecoportal/api/v2/page/component/tag_field.rb, line 16
def configure(*conf)
  conf.each_with_object([]) do |cnf, unused|
    case cnf
    when :single
      self.single_select = true
    when :multiple
      self.single_select = false
    when :default_tag
      self.use_defaults = true
    when Hash
      supported = [:button_text]
      unless (rest = hash_except(cnf.dup, *supported)).empty?
        unused.push(rest)
      end
      if cnf.key?(:button_text) then self.button_text = cnf[:button_text] end
    else
      unused.push(cnf)
    end
  end.yield_self do |unused|
    super(*unused)
  end
end