module Adparlor module Facebook module GraphApi module Traits module Methods def self.included(base) base.extend(ClassMethods) end def create(attributes = {}, options = {}) allowed_methods = self.class.allowed_methods raise FbError.new('create not available', 500) unless allowed_methods && allowed_methods.include?(:create) super(attributes, options) end def destroy(path, options = {}) allowed_methods = self.class.allowed_methods raise FbError.new('destroy not available', 500) unless allowed_methods && allowed_methods.include?(:destroy) super(path, options) end def update(attributes = {}, options = {}) allowed_methods = self.class.allowed_methods raise FbError.new('update not available', 500) unless allowed_methods && allowed_methods.include?(:update) super(attributes, options) end module ClassMethods def allow_local_method(*args) @allowed_local_methods = args end def allow_method(*args) @allowed_methods = args end def allowed_local_methods @allowed_local_methods end def allowed_methods @allowed_methods end def create(path, options = {}) raise FbError.new('create not available', 500) unless @allowed_local_methods && @allowed_local_methods.include?(:create) super(path, options) end def destroy(path, options = {}) raise FbError.new('destroy not available, use soft delete update', 500) unless @allowed_local_methods && @allowed_local_methods.include?(:destroy) super(path, options) end def update(path, options = {}) raise FbError.new('update not available', 500) unless @allowed_local_methods && @allowed_local_methods.include?(:update) super(path, options) end end end end end end end