| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  | module OrbitApp | 
					
						
							|  |  |  |     module Plugin | 
					
						
							|  |  |  |       module Registration | 
					
						
							| 
									
										
										
										
											2013-03-22 06:19:10 +00:00
										 |  |  |       Version = "0.2" | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         module ClassMethods | 
					
						
							|  |  |  |             @@registrations = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           def new( name ,&block) | 
					
						
							|  |  |  |             @@registrations << DataSheet.new(name,&block) | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-22 06:19:10 +00:00
										 |  |  |           def new_from_module_app(name,key,base_path,*args) | 
					
						
							| 
									
										
										
										
											2012-11-20 07:56:52 +00:00
										 |  |  |             @@registrations << DataSheet.new(name,args,:base_path=>base_path) | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-18 09:31:53 +00:00
										 |  |  |           def find_by_app_name(name) | 
					
						
							|  |  |  |             @@registrations.each{|t| | 
					
						
							|  |  |  |               return t if t.app_name == name | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             return nil | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  |           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]) }  | 
					
						
							| 
									
										
										
										
											2013-09-26 12:02:41 +00:00
										 |  |  |             @sort_number = partial[0][:sort_number] | 
					
						
							| 
									
										
										
										
											2013-09-18 09:31:53 +00:00
										 |  |  |             @app_name = partial[0][:app_name] | 
					
						
							|  |  |  |             @intro_app_name = partial[0][:intro_app_name] | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  |             @partial_path = '' | 
					
						
							| 
									
										
										
										
											2013-08-21 03:57:14 +00:00
										 |  |  |             @front_partial_path = '' | 
					
						
							| 
									
										
										
										
											2013-02-20 03:12:08 +00:00
										 |  |  |             @admin_partial_path = '' | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             unless partial.nil? | 
					
						
							| 
									
										
										
										
											2012-11-20 07:56:52 +00:00
										 |  |  |               @partial_path = partial[0][:path] | 
					
						
							| 
									
										
										
										
											2013-08-21 03:57:14 +00:00
										 |  |  |               @front_partial_path = partial[0][:front_path] | 
					
						
							| 
									
										
										
										
											2013-02-20 09:25:20 +00:00
										 |  |  |               @admin_partial_path = partial[0][:admin_path] | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  |             end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-26 12:02:41 +00:00
										 |  |  |           def sort_number | 
					
						
							|  |  |  |             return  @sort_number | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-18 09:31:53 +00:00
										 |  |  |           def app_name | 
					
						
							|  |  |  |             return  @app_name | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           def intro_app_name | 
					
						
							|  |  |  |             return  @intro_app_name | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  |           def profile_partial_path | 
					
						
							|  |  |  |             return  @partial_path | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2013-02-20 03:12:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 03:57:14 +00:00
										 |  |  |           def front_partial_path | 
					
						
							|  |  |  |             return  @front_partial_path | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-20 03:12:08 +00:00
										 |  |  |           def admin_partial_path | 
					
						
							|  |  |  |             return  @admin_partial_path | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2012-09-24 03:43:48 +00:00
										 |  |  |      | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |