Sha256: 114f669d88319954975525437362f127e5403c1fd0ee43d50ad89048129219ad

Contents?: true

Size: 789 Bytes

Versions: 10

Compression:

Stored size: 789 Bytes

Contents

module Piggybak
  module ActsAsVariant
    ## Define ModelMethods
    module Base
      def self.included(klass)
        klass.class_eval do
          extend ClassMethods
        end
      end
      
      module ClassMethods
        def acts_as_variant
          has_one :piggybak_variant, :as => "item", :class_name => "::Piggybak::Variant"

          accepts_nested_attributes_for :piggybak_variant, :allow_destroy => true
          
          include Piggybak::ActsAsVariant::Base::InstanceMethods
        end
      end
      
      module InstanceMethods
        
        def factory_name
          "this is an example instance method"
        end
                
      end # InstanceMethods      
    end
  end
end

::ActiveRecord::Base.send :include, Piggybak::ActsAsVariant::Base

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
piggybak-0.4.4 lib/acts_as_variant/base.rb
piggybak-0.4.3 lib/acts_as_variant/base.rb
piggybak-0.4.2 lib/acts_as_variant/base.rb
piggybak-0.4.1 lib/acts_as_variant/base.rb
piggybak-0.4.0 lib/acts_as_variant/base.rb
piggybak-0.3.2 lib/acts_as_variant/base.rb
piggybak-0.3.1 lib/acts_as_variant/base.rb
piggybak-0.3.0 lib/acts_as_variant/base.rb
piggybak-0.2.1 lib/acts_as_variant/base.rb
piggybak-0.2.0 lib/acts_as_variant/base.rb