v3: drastically reduce objects allocated by access control
This commit is contained in:
parent
a6c90a7237
commit
b0f142a94b
|
@ -8,11 +8,11 @@ module Travis::API::V3
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible?(object)
|
def visible?(object)
|
||||||
full_access? or dispatch(object)
|
full_access? or dispatch(object, :visible?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def writable?(object)
|
def writable?(object)
|
||||||
full_access? or dispatch(object)
|
full_access? or dispatch(object, :writable?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def admin_for(repository)
|
def admin_for(repository)
|
||||||
|
@ -82,7 +82,7 @@ module Travis::API::V3
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def dispatch(object, method = caller_locations.first.base_label)
|
def dispatch(object, method)
|
||||||
method = method_for(object.class, method)
|
method = method_for(object.class, method)
|
||||||
send(method, object) if respond_to?(method, true)
|
send(method, object) if respond_to?(method, true)
|
||||||
end
|
end
|
||||||
|
@ -98,7 +98,8 @@ module Travis::API::V3
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_for(type, method)
|
def method_for(type, method)
|
||||||
@@method_for_cache[[type, method]] ||= "#{normailze_type(type)}_#{method}"
|
type_cache = @@method_for_cache[type] ||= {}
|
||||||
|
type_cache[method] ||= "#{normailze_type(type)}_#{method}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def normailze_type(type)
|
def normailze_type(type)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user