Module: CustomFields::Types::Tags::Target::ClassMethods

Defined in:
lib/custom_fields/types/tags.rb

Instance Method Summary collapse

Instance Method Details

#apply_tags_custom_field(klass, rule) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/custom_fields/types/tags.rb', line 11

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

#tags_attribute_get(instance, name) ⇒ Object



23
24
25
# File 'lib/custom_fields/types/tags.rb', line 23

def tags_attribute_get(instance, name)
  self.default_attribute_get(instance, name)
end

#tags_attribute_set(instance, name, attributes) ⇒ Object



27
28
29
# File 'lib/custom_fields/types/tags.rb', line 27

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