58 lines
1.3 KiB
Ruby
58 lines
1.3 KiB
Ruby
module OrbitApp
|
|
module Plugin
|
|
module Registration
|
|
Version = "0.1"
|
|
|
|
module ClassMethods
|
|
@@registrations = []
|
|
|
|
def new( name ,&block)
|
|
@@registrations << DataSheet.new(name,&block)
|
|
end
|
|
|
|
def new_from_module_app(name,base_path,arg)
|
|
@@registrations << DataSheet.new(name,arg,:base_path=>base_path)
|
|
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,partial=nil,*args ,&block)
|
|
@base_path = args[0][:base_path]
|
|
@name = name
|
|
@partial_path = ''
|
|
|
|
unless partial.nil?
|
|
@partial_path = partial[:path]
|
|
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 |