module StrongConcerns

two way proxy

Constants

VERSION

Public Class Methods

extended(base) click to toggle source
Calls superclass method
# File lib/strong_concerns.rb, line 27
def self.extended(base)
  base.send(:extend, Reflection)
  base.send(:extend, ClassMethods)
  base.send(:include, InstanceMethods)
  super
end

Public Instance Methods

class_concern(mod, options) click to toggle source
# File lib/strong_concerns.rb, line 62
def class_concern(mod, options)
  self.add_class_role(mod, options)
  options.fetch(:exports_methods).each do |meth|
    self.define_singleton_method meth do |*args, &block|
      inter = role_instance(mod)
      unless inter.active?
        raise RoleNotActive.new("Your call method <#{meth}> of inactive role <#{mod.name}>!")
      end
      inter.inactivate
      inter.send(meth,*args, &block)
    end
  end
end
concern(mod, options) click to toggle source
# File lib/strong_concerns.rb, line 34
def concern(mod, options)
  self.add_instance_role(mod, options)
  options.fetch(:exports_methods).each do |meth|
    self.send(:define_method, meth) do |*args, &block|
      inter = role_instance(mod)
      unless inter.active?
        raise RoleNotActive.new("Your call method <#{meth}> of inactive role <#{mod.name}>!")
      end
      inter.send(meth,*args, &block)
    end
  end
end