Sha256: 05600ec426c9365f0423b5f09f58821bb3cb17e5347b352581942469019a4b7a
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
module Sunrise class Plugin attr_accessor :name, :model, :menu, :version, :klass, :klass_name def initialize(name) @name = name.to_s.downcase @menu = false @klass = nil @klass_name = nil Sunrise::Plugins.registered << self end def module_name @module_name ||= @name.singularize.camelize.to_sym end def klass @klass ||= klass_name.constantize end def klass_name @klass_name ||= @name.singularize.camelize end def title I18n.t(@name, :scope => [:manage, :plugins]) end def self.register(name, &block) plugin = self.new(name) yield plugin raise "A plugin MUST have a name!: #{plugin.inspect}" if plugin.name.blank? plugin.version ||= Sunrise::VERSION.dup if plugin.model model_path = (plugin.model == true ? "sunrise/models/#{plugin.name}" : plugin.model) Sunrise::Models.send(:autoload, plugin.module_name, model_path) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sunrise-core-0.1.3 | lib/sunrise/plugin.rb |
sunrise-core-0.1.2 | lib/sunrise/plugin.rb |
sunrise-core-0.1.1 | lib/sunrise/plugin.rb |
sunrise-core-0.1.0 | lib/sunrise/plugin.rb |