Class: ActionFlow::BlankSlate

Inherits:
Object
  • Object
show all
Defined in:
lib/action_flow/blank_slate.rb

Direct Known Subclasses

DSL

Class Method Summary collapse

Class Method Details

.all_methods(klass, include_ancestors = false) ⇒ Object



24
25
26
27
28
29
# File 'lib/action_flow/blank_slate.rb', line 24

def self.all_methods(klass, include_ancestors = false)
  %w[public protected private].map { |viz|
    klass.__send__("#{viz}_instance_methods", include_ancestors)
  }.
  flatten.map { |m| m.to_sym }.uniq
end

.include(mixin) ⇒ Object



4
5
6
7
8
# File 'lib/action_flow/blank_slate.rb', line 4

def self.include(mixin)
  super(mixin)
  @mixins ||= []
  @mixins << mixin
end

.new(*args, &block) ⇒ Object



10
11
12
13
# File 'lib/action_flow/blank_slate.rb', line 10

def self.new(*args, &block)
  remove_inherited_methods
  super(*args, &block)
end

.remove_inherited_methodsObject



15
16
17
18
19
20
21
22
# File 'lib/action_flow/blank_slate.rb', line 15

def self.remove_inherited_methods
  modules = [self] + (@mixins || [])
  
  keepers = modules.inject([]) { |list, klass| list + all_methods(klass) } +
            [:__id__, :__send__, :instance_eval]
  
  undef_method *( all_methods(self, true) - keepers )
end