bruce (owner)

Forks

Revisions

gist: 73916 Download_button fork
public
Public Clone URL: git://gist.github.com/73916.git
Embed All Files: show embed
model-mixin-example.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Sold
 
  def self.included(base)
    base.extend ClassMethods
    base.instance_eval do
      belongs_to :seller, :polymorphic => true
      include InstanceMethods
    end
  end
  
  module ClassMethods
    # seller-related class methods
  end
  
  module InstanceMethods
    # seller-related instance methods
  end
 
end
 
TheModel.send(:include, Sold)