Skip to content

Instantly share code, notes, and snippets.

@javier
Forked from littlemove/gist:403648
Created May 17, 2010 11:41
Show Gist options
  • Select an option

  • Save javier/403676 to your computer and use it in GitHub Desktop.

Select an option

Save javier/403676 to your computer and use it in GitHub Desktop.

Revisions

  1. javier revised this gist May 17, 2010. 1 changed file with 5 additions and 11 deletions.
    16 changes: 5 additions & 11 deletions gistfile1.builder
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,13 @@
    module Categorizable

    def self.included(base)

    base.has_many :audience_scopes, :as => :audienciable
    base.has_many :audience_categories, :through => :audience_scopes

    base.has_many :areas, :through => :audience_scopes
    ...

    base.send :extend, ClassMethods
    end

    module ClassMethods

    def acts_as_categorizable
    has_many :audience_scopes, :as => :audienciable
    has_many :audience_categories, :through => :audience_scopes

    has_many :areas, :through => :audience_scopes

    send :include, InstanceMethods
    end

  2. @littlemove littlemove created this gist May 17, 2010.
    35 changes: 35 additions & 0 deletions gistfile1.builder
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    module Categorizable

    def self.included(base)

    base.has_many :audience_scopes, :as => :audienciable
    base.has_many :audience_categories, :through => :audience_scopes

    base.has_many :areas, :through => :audience_scopes
    ...

    base.send :extend, ClassMethods
    end

    module ClassMethods

    def acts_as_categorizable
    send :include, InstanceMethods
    end

    def for_user(user)
    ...
    end

    end

    module InstanceMethods

    def related
    ...
    end

    end
    end

    ActiveRecord::Base.send :include, Categorizable