representation

Create different, named representations of a resource for cleaner state representation. See: en.wikipedia.org/wiki/Representational_State_Transfer#Central_principle

Install

gem 'representation'
bundle

Usage

“‘ruby class User < ActiveRecord::Base representation :public, :name, :calculated_age representation :internal, :name, :ssn, :age

def calculated_age age * 2 end end

User.first.representation(:public).inspect => #<User name: “Tweedle Dum”, calculated_age: 84>

User.first.representation(:internal).inspect => #<User name: “Tweedle Dum”, age: 42, ssn: “555-55-5555”> ““

Contributing to representation

Copyright © 2011 Chris Johnson, SocialVibe. See LICENSE.txt for further details.