Module: Surrounded

Defined in:
lib/surrounded.rb,
lib/surrounded/context.rb,
lib/surrounded/version.rb,
lib/surrounded/context_errors.rb,
lib/surrounded/context/role_map.rb,
lib/surrounded/context/negotiator.rb

Defined Under Namespace

Modules: Context, Contextual Classes: NullContext

Constant Summary collapse

VERSION =
"0.6.0"

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (private)



50
51
52
# File 'lib/surrounded.rb', line 50

def method_missing(meth, *args, &block)
  context.role?(meth){} || super
end

Class Method Details

.extended(object) ⇒ Object



16
17
18
# File 'lib/surrounded.rb', line 16

def self.extended(object)
  Surrounded.create_surroundings(object)
end

.included(klass) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/surrounded.rb', line 5

def self.included(klass)
  klass.class_eval {
    extend Surrounded::Contextual
  }
  unless klass.is_a?(Class)
    def klass.extended(object)
      Surrounded.create_surroundings(object)
    end
  end
end

Instance Method Details

#remove_contextObject



32
33
34
# File 'lib/surrounded.rb', line 32

def remove_context
  surroundings.shift
end

#store_context(ctxt) ⇒ Object



28
29
30
# File 'lib/surrounded.rb', line 28

def store_context(ctxt)
  surroundings.unshift(ctxt)
end