Sha256: 77909f6995cd43091515bd17ae2abc782a3c16b18a806ede9e327d1f4f7766a6

Contents?: true

Size: 429 Bytes

Versions: 4

Compression:

Stored size: 429 Bytes

Contents

# frozen_string_literal: true

module LazyRecord
  # Macro for dynamic instance method generation. Best to use for one-liners.
  module Methods
    METHODS_MODULE_NAME = :DynamicMethods

    def lr_method(method_name, method)
      include mod = get_or_set_mod(METHODS_MODULE_NAME)

      mod.module_eval do
        define_method(method_name) do |*args|
          method.call(self, *args)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazy_record-0.6.3 lib/lazy_record/methods.rb
lazy_record-0.6.2 lib/lazy_record/methods.rb
lazy_record-0.6.1 lib/lazy_record/methods.rb
lazy_record-0.6.0 lib/lazy_record/methods.rb