Created
August 21, 2009 08:45
-
-
Save ehlyzov/171732 to your computer and use it in GitHub Desktop.
This file contains 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 ProteinPresenter | |
custom_presenter = lambda { |att| att.to_s } | |
# тут делаются презентеры, хотя лучше из выносить вообще в | |
# отдельные файлы. Существующих возможностей для этого куча. | |
presenter :title, lambda {|att| attr.capitalize } | |
presenter :num, custom_presenter | |
presenter :m2, lambda {|m| m.to_s.capitalize } | |
end | |
output :json | |
alias :protein_hits, :proteins | |
context :root, :storage => :hash # {} | |
context :proteins, :storage => :array, :anchor => :data # { :data => [] } | |
context.each do |protein| | |
protein.extend(ProteinPresenter) | |
context :protein, :storage => :hash # { :data => [{}] | |
attributes :all, :except => [:created_at, :updated_at] | |
methods :m1, :m2, [:m3, param1, param2] | |
context :taggings, :storage => :array # {:data => [{..., :taggings => []}] | |
context.each do |tag| | |
context :tag, :storage => :hash | |
attributes :only => [:title, :creator_id] | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment