Ukagaka SHIORI subsystem 'Sana' MVC Helper
Installation
Add this line to your application's Gemfile:
gem 'sana-mvcbase'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sana-mvcbase
Usage
require 'sana-mvcbase'
require 'shiolink'
# define controllers
# for load(), unload()
class DLController < SanaController
def _load(dirpath)
MySave.load
p dirpath
end
def _unload
p :unload
end
end
# view rendering module
module MyViewModule
def render_response(name)
MyView.talk(name || event_id)
end
end
# view rendering base controller
class MyWithViewController < SanaAnyEventController
include MyViewModule
end
# normal talk controller
class TalkEventsController < MyWithViewController
def OnBoot
@foo = MySave.foo_flag
@bar = MyModel.bar(params.shell_name)
end
def OnFirstBoot
@foo = MySave.foo_flag
render :OnBoot
end
end
# resource controller
class ResourcesController < SanaController
def homeurl
"http://www.example.com/foo/"
end
end
# register routing
router = SanaRouter.new(TalkEventsController)
router.draw do
controller DLController do
load
unload
end
controller ResourcesController do
route :homeurl
end
route :OnBoot, {shell_name: 0, halted: 6, halted_ghost_name: 7}
# OnFirstBoot is not registered but will called with default controller (= TalkEventsController)
end
# app start
sana = Sana.new(router.events)
shiolink = Shiolink.new(sana.method(:load), sana.method(:unload), sana.method(:request))
shiolink.start
API
License
This is released under MIT License.