Sha256: eaa2669f577a22100ebe4d5e47f9f0635001ebad4552eeb9c909a2f23066c294

Contents?: true

Size: 468 Bytes

Versions: 3

Compression:

Stored size: 468 Bytes

Contents

module Structural
  module Model
    class Definer
      def self.method_memoize(context, name, &value_block)
        method(context, name) do |object|
          object.instance_eval do
            memoize(name, &value_block)
          end
        end
      end

      def self.method(context, name, &value_block)
        context.instance_eval do
          define_method name do
            value_block.call(self)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
structural-0.0.3 lib/structural/model/definer.rb
structural-0.0.2 lib/structural/model/definer.rb
structural-0.0.1 lib/structural/model/definer.rb