New authorization

This commit is contained in:
chris committed 2013-08-21 13:42:29 +08:00
1 parent d24bd176cc
commit c474fa063f
25 files changed
+440 -172

No files matched your search

+16 -2
View File
@@ -28,7 +28,7 @@ module OrbitApp
end
class DataSheet
attr_reader :name,:key,:base_path,:module_label,:data_count, :has_category, :has_tag, :authorizable_models, :is_approvable, :is_authorizable
attr_reader :name,:key,:base_path,:module_label,:data_count, :has_category, :has_tag, :approvable_models, :authorizable_models, :is_approvable, :is_authorizable
def initialize(name, &block)
@name = name
@@ -39,6 +39,7 @@ module OrbitApp
@data_count = 1..15 # as default
@has_category = nil
@has_tag = nil
@approvable_models = []
@authorizable_models = []
@is_approvable = nil
@is_authorizable = nil
@@ -145,8 +146,13 @@ module OrbitApp
define_method(field){|var| instance_variable_set( "@" + field, var)}
end
def approvable(link=true)
def approvable(link=true, &block)
@is_approvable = {:with_link => link}
if block
block.call
else
approvable_on
end
end
def authorizable(link=true, &block)
@@ -158,6 +164,10 @@ module OrbitApp
end
end
def approvable_on(klass = 'Category')
@approvable_models << klass
end
def authorizable_on(klass = 'Category')
@authorizable_models << klass
end
@@ -170,6 +180,10 @@ module OrbitApp
@has_tag = true
end
def get_approvable_models
@approvable_models
end
def get_authorizable_models
@authorizable_models
end