Sha256: 7896a14c70092ceabc05c572f73c1b3c04b6d9a60d205c8748278abe2d7350dd

Contents?: true

Size: 963 Bytes

Versions: 36

Compression:

Stored size: 963 Bytes

Contents

module CustomFields
  module Types
    module Tags
      module Field; end
      
      module Target
        extend ActiveSupport::Concern
        
        module ClassMethods

          def apply_tags_custom_field(klass, rule)
            klass.field rule['name'], localize: rule['localized'] || false, type: Array
            
            klass.class_eval do
              define_method("#{rule['name']}=") do |val|
                #FIXME I would use is_a?(), but it doesn't work in my machine!
                val = val.split(/ *, */) if val.class.to_s == "String" 
                super(val)
              end
            end
          end
          
          def tags_attribute_get(instance, name)
            self.default_attribute_get(instance, name)
          end

          def tags_attribute_set(instance, name, attributes)
            self.default_attribute_set(instance, name, attributes)
          end
        end
      end
      
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
custom_fields-2.12.1 lib/custom_fields/types/tags.rb
custom_fields-2.12.0 lib/custom_fields/types/tags.rb
custom_fields-2.10.0 lib/custom_fields/types/tags.rb
custom_fields-2.10.0.rc1 lib/custom_fields/types/tags.rb
custom_fields-2.10.0.beta3 lib/custom_fields/types/tags.rb
custom_fields-2.10.0.beta2 lib/custom_fields/types/tags.rb
custom_fields-2.9.0 lib/custom_fields/types/tags.rb
custom_fields-2.9.0.rc2 lib/custom_fields/types/tags.rb
custom_fields-2.9.0.rc1 lib/custom_fields/types/tags.rb
custom_fields-2.8.0 lib/custom_fields/types/tags.rb
custom_fields-2.7.0 lib/custom_fields/types/tags.rb
custom_fields-2.7.0.rc1 lib/custom_fields/types/tags.rb
custom_fields-2.6.0 lib/custom_fields/types/tags.rb
custom_fields-2.5.0 lib/custom_fields/types/tags.rb
custom_fields-2.5.0.rc1 lib/custom_fields/types/tags.rb
custom_fields-2.4.0.rc8 lib/custom_fields/types/tags.rb
custom_fields-2.4.0.rc7 lib/custom_fields/types/tags.rb
custom_fields-2.4.0.rc6 lib/custom_fields/types/tags.rb
custom_fields-2.3.4 lib/custom_fields/types/tags.rb
custom_fields-2.4.0.rc5 lib/custom_fields/types/tags.rb