This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first we will give Domains a little help | |
class Domain < String | |
def subdomain( rank = 1 ) ; self.split('.')[0..(rank-1)].join('.') ; end | |
def level( rank ) ; self.split('.')[(rank*-1)..-1].join('.') ; end | |
def top_level ; level(1) ; end | |
end | |
# now we can treat them like strings but also access domain components naturally |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def satisfy?( request ) | |
METHODS.all? do | method | | |
wanted = instance_variable_get( "@#{method}") | |
got = request.send( method ) if wanted | |
wanted.is_a? Proc ? wanted.call( got ) : wanted === got | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Default | |
def add ; action( :create ) and redirect( paths.show ) ; end | |
def update | |
action( :update, name ) and redirect( resource( :site ).paths.main ) | |
end | |
def delete | |
action( :delete, name ) and redirect( resource( :site ).paths.main ) | |
end | |
def edit ; action( :find, name ) and render( :editor ) } ; end | |
def show ; action( :find, name ) and render( :show ) ; end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ypcmc02106:pages dyoder$ irb | |
>> load 'startup.rb' | |
=> true | |
>> with | |
ArgumentError: wrong number of arguments (0 for 1) | |
from (irb):2:in `with' | |
from (irb):2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lambda { | |
string_or_symbol = lambda { |arg| arg.kind_of?(String) || arg.kind_of?(Symbol) } | |
Waves::ResponseMixin.module_eval do | |
[ :models, :controllers, :views, :helpers ].each do |k| | |
functor( k ) { app[ k ] } | |
functor( k, string_or_symbol ) { |name| app( name )[ k ] } | |
end | |
end | |
}.call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Breakpoint 1 at autocode.rb:52 | |
/opt/local/lib/ruby/gems/1.8/gems/autocode-1.0.0/lib/autocode.rb:52 | |
Kernel.load( path ) unless path.nil? | |
(rdb:3) path | |
"helpers/default.rb" | |
(rdb:3) self | |
Pages::Helpers | |
(rdb:3) Kernel.load( path ) | |
true | |
(rdb:3) const_defined?( :Default ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# special rule to handle rss blog feed | |
blog.feed when get /blog/:name and accepts rss | |
with resource = site | |
authenticated when before get /admin/* | |
login when get /login | |
authenticate when post /login | |
main when get /admin | |
update when post /admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before: | |
authenticated?: { get: /?resource/?name/edit } | |
blog.feed: { get: /blog/?name, accepts: rss } | |
default.edit: { get: /?resource/?name/edit } | |
media.get: { get: /?media/?path[*] } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before do | |
on( :get => [ 'admin', true ], :resource => :admin ) { authenticated? } | |
end | |
after do | |
... | |
end | |
always do | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Pages | |
module Resources | |
class Default < Waves::Resources::Base | |
def add | |
controller.create and redirect( paths.show ) | |
end | |
OlderNewer