2012-09-24 03:43:48 +00:00
|
|
|
module OrbitApp
|
|
|
|
module Module
|
|
|
|
module Registration
|
|
|
|
Version = "0.1"
|
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
@@registrations = []
|
|
|
|
|
|
|
|
def new( name ,&block)
|
|
|
|
@@registrations << DataSheet.new(name,&block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_by_key(key)
|
|
|
|
@@registrations.each{|t|
|
|
|
|
return t if t.name == key
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def all
|
|
|
|
return @@registrations
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
extend ClassMethods
|
|
|
|
def self.included( other )
|
|
|
|
other.extend( ClassMethods )
|
|
|
|
end
|
|
|
|
|
|
|
|
class DataSheet
|
|
|
|
attr_reader :name
|
|
|
|
attr_reader :base_path
|
|
|
|
|
|
|
|
def initialize(name, &block)
|
|
|
|
@name = name
|
2012-11-20 07:56:52 +00:00
|
|
|
@side_bar = nil
|
2012-09-24 03:43:48 +00:00
|
|
|
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
|
|
|
end
|
|
|
|
|
2012-11-20 07:56:52 +00:00
|
|
|
def side_bar(&block)
|
|
|
|
@side_bar = SideBarRegisition::SideBar.new(&block)
|
|
|
|
@side_bar.module_app_key = @name
|
|
|
|
@side_bar.finalize!
|
|
|
|
OrbitApp::Module::SideBarRegisition.add(@side_bar)
|
2012-09-24 03:43:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def personal_plugin(params)
|
|
|
|
# TODO 這裡要看是一些檔案是不是都有
|
|
|
|
Plugin::Registration.new_from_module_app(@name,@base_path,params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def base_url(var)
|
|
|
|
@base_path = var
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|