Sha256: acfc0fe783f030ed7470768e26300c657d18d4130d9cdfaec11fe4a54b2d6490

Contents?: true

Size: 474 Bytes

Versions: 62

Compression:

Stored size: 474 Bytes

Contents

module Mongoid
  module ListField
    def list_field(name)
      self.class_eval <<-RUBY
        def #{name}_list
          #{name}.join(', ') if #{name}.present?
        end

        def #{name}_list=(val)
          if val.blank?
            self.#{name} = []
          else
            self.#{name} = val.split(',').map(&:strip).delete_if(&:blank?)
          end
        end
      RUBY
    end
  end
end

Mongoid::Document::ClassMethods.send(:include, Mongoid::ListField)

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.26 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.45 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.25 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.23 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.44 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.22 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.43 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.21 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.42 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.20 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.41 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.19 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.40 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.18 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.39 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.17 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.38 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.5.16 lib/workarea/ext/mongoid/list_field.rb
workarea-core-3.4.37 lib/workarea/ext/mongoid/list_field.rb