Created
December 2, 2010 01:24
-
-
Save dyoder/724574 to your computer and use it in GitHub Desktop.
Current Example - Listing 1
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 Acme::Web::Adapters::Article < Acme::Web::Adapter | |
| resource Acme::Resources::Article | |
| Comments = Acme::Web::Adapters::Comments | |
| version "1.0" do | |
| path "article", :name | |
| get [ json, xml, html ] | |
| authorized do | |
| put json => json, xml => xml | |
| delete | |
| end | |
| representation html do |resource| | |
| Acme::Web::Views::Article.render(resource) | |
| end | |
| schema :title, :content, :published, | |
| { :comments_url => :url } | |
| end | |
| version "1.1" do | |
| inherit "1.0" | |
| path "articles", :name | |
| schema :title, :subtitle, :content, :published, | |
| { :comments_url => :url } | |
| 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 Acme::Resources::Article | |
| include Current::Resources::Mixin | |
| 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
| Acme::Resources::Article["introduction"] = { | |
| :title => "Introducing Current", :published => Time.now, | |
| :content => "This is the introduction" } | |
| article = Acme::Resources::Article["introduction"] | |
| article.content # => "This is the introduction" | |
| article.content = "We need a better introduction!" | |
| Acme::Resources::Articles["introduction"] = { | |
| :title => "Introduction To Current", :published => Time.now, | |
| :content => "This is the introduction" } | |
| Acme::Resources::Articles["introduction"].title | |
| # => "Introduction To Current" | |
| Acme::Resources::Articles.to_h | |
| # => { :title => "Introduction To Current", ... | |
| Acme::Resources::Articles["introduction"].delete | |
| Acme::Resources::Articles["introduction"] # => nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment