Sha256: 7f4b0d5c9d27fdc93b63a37a2ff27bf36b799a68cd36dbe3bfe9885f3250098f

Contents?: true

Size: 614 Bytes

Versions: 5

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

module Mongoid
module Orderable
module Generators
  class Position < Base
    def generate(field_name)
      klass.class_eval <<~KLASS, __FILE__, __LINE__ + 1
        def orderable_position(field = nil)
          field ||= default_orderable_field
          send "orderable_\#{field}_position"
        end
      KLASS

      generate_method("orderable_#{field_name}_position") do
        send field_name
      end

      generate_method("orderable_#{field_name}_position=") do |value|
        send "#{field_name}=", value
      end
    end
  end
end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mongoid_orderable-6.0.4 lib/mongoid/orderable/generators/position.rb
mongoid_orderable-6.0.3 lib/mongoid/orderable/generators/position.rb
mongoid_orderable-6.0.2 lib/mongoid/orderable/generators/position.rb
mongoid_orderable-6.0.1 lib/mongoid/orderable/generators/position.rb
mongoid_orderable-6.0.0 lib/mongoid/orderable/generators/position.rb