Class: Spree::Extension

Inherits:
Object show all
Includes:
Annotatable, Simpleton
Defined in:
lib/spree/extension.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Annotatable

included

Methods included from Simpleton

included

Instance Attribute Details

#active=(value) ⇒ Object (writeonly)

Sets the attribute active

Parameters:

  • value

    the value to set the attribute active to.



12
13
14
# File 'lib/spree/extension.rb', line 12

def active=(value)
  @active = value
end

Class Method Details

.activate_extensionObject Also known as: activate



32
33
34
35
36
37
# File 'lib/spree/extension.rb', line 32

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

.define_routes(&block) ⇒ Object



40
41
42
# File 'lib/spree/extension.rb', line 40

def define_routes(&block)
  route_definitions << block
end

.inherited(subclass) ⇒ Object



44
45
46
# File 'lib/spree/extension.rb', line 44

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

.metaObject



48
49
50
# File 'lib/spree/extension.rb', line 48

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

.route_definitionsObject



52
53
54
# File 'lib/spree/extension.rb', line 52

def route_definitions        
  @route_definitions ||= []
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/spree/extension.rb', line 14

def active?
  @active
end

#metaObject

def admin

  AdminUI.instance
end


26
27
28
# File 'lib/spree/extension.rb', line 26

def meta
  self.class.meta
end

#migratorObject



18
19
20
# File 'lib/spree/extension.rb', line 18

def migrator
  ExtensionMigrator.new(self)
end