Sha256: aafdd2e146523fb0b29334c4199c6c19dfaf2add52c76552dd41dc7895a3e200

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

require 'annotatable'
require 'simpleton'
#require 'radiant/admin_ui'

module Spree
  class Extension
    include Simpleton
    include Annotatable

    annotate :version, :description, :url, :root, :extension_name

    attr_writer :active

    def active?
      @active
    end
    
    def migrator
      ExtensionMigrator.new(self)
    end
=begin
    def admin
      AdminUI.instance
    end
=end
    def meta
      self.class.meta
    end

    class << self

      def activate_extension
        return if instance.active?
        instance.activate if instance.respond_to? :activate
        #ActionController::Routing::Routes.reload
        instance.active = true
      end
      alias :activate :activate_extension

      def define_routes(&block)
        route_definitions << block
      end

      def inherited(subclass)
        subclass.extension_name = subclass.name.to_name('Extension')
      end

      def meta
        Spree::ExtensionMeta.find_or_create_by_name(extension_name)
      end

      def route_definitions        
        @route_definitions ||= []
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
kdmny-spree-0.0.1 lib/spree/extension.rb
spree-enriquez-0.9.4 lib/spree/extension.rb
spree-0.9.4 lib/spree/extension.rb
spree-0.9.3 lib/spree/extension.rb
spree-0.9.2 lib/spree/extension.rb
spree-0.9.1 lib/spree/extension.rb
spree-0.9.0 lib/spree/extension.rb
spree-0.8.4 lib/spree/extension.rb
spree-0.8.5 lib/spree/extension.rb
spree-0.5.0 lib/spree/extension.rb
spree-0.5.1 lib/spree/extension.rb
spree-0.6.0 lib/spree/extension.rb
spree-0.7.1 lib/spree/extension.rb
spree-0.7.0 lib/spree/extension.rb
spree-0.8.0 lib/spree/extension.rb
spree-0.8.1 lib/spree/extension.rb
spree-0.8.2 lib/spree/extension.rb
spree-0.8.3 lib/spree/extension.rb