This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
2012-09-24 03:43:48 +00:00
|
|
|
module OrbitApp
|
|
|
|
module Plugin
|
|
|
|
module Registration
|
|
|
|
Version = "0.1"
|
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
@@registrations = []
|
|
|
|
|
|
|
|
def new( name ,&block)
|
|
|
|
@@registrations << DataSheet.new(name,&block)
|
|
|
|
end
|
|
|
|
|
2012-11-20 07:56:52 +00:00
|
|
|
def new_from_module_app(name,base_path,*args)
|
|
|
|
@@registrations << DataSheet.new(name,args,:base_path=>base_path)
|
2012-09-24 03:43:48 +00:00
|
|
|
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
|
|
|
|
|
2012-11-20 07:56:52 +00:00
|
|
|
def name
|
|
|
|
if @name.is_a? Proc
|
|
|
|
@name.call
|
|
|
|
else
|
|
|
|
@name
|
|
|
|
end
|
|
|
|
end
|
2012-09-24 03:43:48 +00:00
|
|
|
|
|
|
|
def initialize(name,partial=nil,*args ,&block)
|
|
|
|
@base_path = args[0][:base_path]
|
2012-11-20 07:56:52 +00:00
|
|
|
@name = partial[0][:i18n].nil? ? name : lambda{ I18n.t(partial[0][:i18n]) }
|
2012-09-24 03:43:48 +00:00
|
|
|
@partial_path = ''
|
|
|
|
|
|
|
|
unless partial.nil?
|
2012-11-20 07:56:52 +00:00
|
|
|
@partial_path = partial[0][:path]
|
2012-09-24 03:43:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
|
|
|
end
|
|
|
|
|
|
|
|
def profile_partial_path
|
|
|
|
return @partial_path
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|