Module: Plug::Mixin::ClassMethods

Defined in:
lib/zbox/ext/plug.rb

Instance Method Summary collapse

Instance Method Details

#array_attr(attr) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/zbox/ext/plug.rb', line 10

def array_attr(attr)
  attr = attr.to_s
  self.class_eval(%Q{
    def #{attr}_list
      return "" if self.#{attr}.blank?  
      self.#{attr}.join(",")
    end
    def #{attr}_list=(value)
      self.#{attr} = value.split(",") if !value.blank?
    end
  })
end