Sha256: 7b03e879ba7183f473dd9d7af37694f503ac3361a6b53351644027284428a481

Contents?: true

Size: 527 Bytes

Versions: 2

Compression:

Stored size: 527 Bytes

Contents

require 'push_type/tag_list_query'

module PushType
  class TagListField < PushType::FieldType

    include PushType::Fields::Arrays

    options template: 'tag_list', html_options: { multiple: true, placeholder: 'Tags...' }

    def to_json(val)
      super.reject(&:blank?) if val.present?
    end

    initialized_on_node do |object, field|
      object.define_singleton_method "all_#{ field.name }".to_sym do |*args|
        TagListQuery.new(field.name, object.name.underscore.to_sym).all *args
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
push_type_core-0.5.0 app/fields/push_type/tag_list_field.rb
push_type_core-0.5.0.alpha.5 app/fields/push_type/tag_list_field.rb