Skip to content

Instantly share code, notes, and snippets.

@ehlyzov
Created August 21, 2009 09:03
Show Gist options
  • Save ehlyzov/171774 to your computer and use it in GitHub Desktop.
Save ehlyzov/171774 to your computer and use it in GitHub Desktop.
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(:proteins).each do |protein|
extend ProteinPresenter
attributes :all, :except => [:created_at, :updated_at]
methods :m1, :m2, [:m3, param1, param2]
context(:taggings).each do |tag|
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