Module: NamedReturn::Core

Defined in:
lib/named_return/core.rb

Overview

Mix in to your class to make the magic happen.

Defined Under Namespace

Modules: ClassMethods

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.optionsObject

raw options that later get set on config



29
30
31
# File 'lib/named_return/core.rb', line 29

def options
  @options
end

Class Method Details

.[](**options) ⇒ Object

Set config options local to your class.



33
34
35
# File 'lib/named_return/core.rb', line 33

def self.[](**options)
  clone.tap { |cls| cls.options = options }
end

.included(obj) ⇒ Object



37
38
39
40
41
42
# File 'lib/named_return/core.rb', line 37

def self.included(obj)
  proxy = Proxy.new(options || {}) # creating a closure
  obj.send(:define_singleton_method, :_named_return_proxy) { proxy }
  # obj.send(:private, :_named_return_proxy)
  obj.extend clone.const_get(:ClassMethods)
end