Module: StrongConcerns

Defined in:
lib/strong_concerns.rb,
lib/strong_concerns/version.rb

Defined Under Namespace

Classes: Intermediate

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Instance Method Details

#class_concern(mod, options) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/strong_concerns.rb', line 23

def class_concern(mod, options)
  intermediate_class = prepare_intermediate(mod)
  options.fetch(:exports_methods).each do |meth|
    self.define_singleton_method meth do |*args, &block|
  ((@__strong_concerns ||= {})[mod.to_s] ||= intermediate_class.new(self, options)).send(meth,*args, &block)
    end
  end
end

#concern(mod, options) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/strong_concerns.rb', line 32

def concern(mod, options)
  intermediate_class = prepare_intermediate(mod)
  options.fetch(:exports_methods).each do |meth|
    self.send(:define_method, meth) do |*args, &block|
  ((@__strong_concerns ||= {})[mod.to_s] ||= intermediate_class.new(self, options)).send(meth,*args, &block)
    end
  end
end