Sha256: 845d2cb07377291e58253e4ce45ae910da4ced00ed6081be70848d7a37635973

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

MotionResource::Base.root_url = 'http://example.com/'

class Post < MotionResource::Base
  attr_accessor :text
  
  self.member_url = 'posts/:id'
  
  has_many :comments
  has_many :parent_posts, :class_name => 'Post'
end

class Comment < MotionResource::Base
  attr_accessor :post_id, :account_id, :text
  
  self.member_url = 'comments/:id'
  self.collection_url = 'comments'
  
  belongs_to :post
  belongs_to :account, :class_name => 'User'
  scope :recent, :url => 'comments/recent'
  custom_urls :by_user_url => 'comments/by_user/:name'
end

class CustomRootComment < Comment
  def self.json_root
    'custom'
  end
end

class User < MotionResource::Base
  self.member_url = 'users/:id'
  
  has_one :profile
end

class Profile < MotionResource::Base
  attr_accessor :name, :email
end

class Shape < MotionResource::Base
  attribute :contents, :position
  attr_accessor :created_at
end

class Rectangle < Shape
  attribute :size
end

class Membership < MotionResource::Base
  self.primary_key = :membership_id
  attr_accessor :membership_id
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion-resource-0.1.4 spec/env.rb