Module: Poniard::Controller

Defined in:
lib/poniard/controller.rb

Overview

Mixing this module into a Rails controller provides the poniard DSL to that controller. To enable poniard on all controllers, mix this in to ‘ApplicationController`.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



7
8
9
# File 'lib/poniard/controller.rb', line 7

def self.included(klass)
  klass.extend(ClassMethods)
end

Instance Method Details

#inject(method) ⇒ Object

Call the given method via the poniard injector. A ‘ControllerSource` is provided as default, along with any sources passed to `provided_by`.



13
14
15
16
17
18
# File 'lib/poniard/controller.rb', line 13

def inject(method)
  injector = Injector.new [
    ControllerSource.new(self)
  ] + self.class.sources.map(&:new)
  injector.eager_dispatch self.class.provided_by.new.method(method)
end