Orbit/lib/orbit_app/module/front_end.rb

68 lines
1.6 KiB
Ruby

module OrbitApp
module Module
module FrontendUtility
Version = "0.1"
module ClassMethods
@@frontend_pages = []
#Record all frontend pages of orbit
def add(var) #build @@frontend_pages
@@frontend_pages << var
end
def all #return all frontend_pages of orbit
return @@frontend_pages
end
end
extend ClassMethods
def self.included( other )
other.extend( ClassMethods )
end
class AppPageSet # From Registration
def initialize(&block)
@frontend_pages = []
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
end
def app_page(name,&block)
@frontend_pages << AppPage.new(name,&block)
end
def to_module_app_format #For ModuleApp to fetch data
@frontend_pages.collect{|t| [t.get_i18n,t.name]}
end
end
class AppPage
attr_reader :name
def initialize(name,&block)
@name = name
@frontend_i18n = 'rulingcom.errors.init.app_page_noname'
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
end
def frontend_i18n(i18n)
@frontend_i18n = i18n
end
def get_i18n
@frontend_i18n
end
def finalize!
end
protected
end# of AppPage
end # of FrontendUtility
end # of Module
end # of OrbitApp