class Extentions::Base::Extention
Attributes
context[R]
model[R]
Public Class Methods
apply(*params)
click to toggle source
# File lib/extentions/base/extention.rb, line 7 def self.apply(*params) extention = new(*params) extention.valid? ? extention : Null::Extention.new end
config()
click to toggle source
# File lib/extentions/base/extention.rb, line 16 def self.config @config ||= OpenStruct.new end
configure(&block)
click to toggle source
# File lib/extentions/base/extention.rb, line 12 def self.configure(&block) block.call(config) end
new(model, context)
click to toggle source
# File lib/extentions/base/extention.rb, line 41 def initialize(model, context) @model = model @context = context end
Public Instance Methods
process()
click to toggle source
# File lib/extentions/base/extention.rb, line 24 def process router.process end
render()
click to toggle source
# File lib/extentions/base/extention.rb, line 20 def render router.render end
to_token()
click to toggle source
# File lib/extentions/base/extention.rb, line 28 def to_token self.class.name.split("::").at(1).downcase.to_sym # Naming.new(self).tokens.last end
valid?(*)
click to toggle source
# File lib/extentions/base/extention.rb, line 33 def valid?(*) raise NotImplementedError end
Private Instance Methods
config()
click to toggle source
# File lib/extentions/base/extention.rb, line 46 def config self.class.config end
controller()
click to toggle source
# File lib/extentions/base/extention.rb, line 58 def controller Controller.new(model, view) end
model_is_any_of?(*classes)
click to toggle source
# File lib/extentions/base/extention.rb, line 66 def model_is_any_of?(*classes) # Note that '&' is the set intersection operator for Arrays. (classes.map(&:to_s) & model.class.ancestors.map(&:name)).any? end
role()
click to toggle source
# File lib/extentions/base/extention.rb, line 54 def role Factory.new(config.adapter).role_for(model) end
router()
click to toggle source
# File lib/extentions/base/extention.rb, line 62 def router Router.new(controller, role, context) end
view()
click to toggle source
# File lib/extentions/base/extention.rb, line 50 def view Extentions::Renderer.new(self) end