Permalink
Browse files

refactor .methods and .respond_to? to use a single remote_model_metho…

…ds array.
  • Loading branch information...
1 parent 12cfe4a commit 3fccd330baebb47dfbb69c81902708d311d8f30e @clayallsopp committed May 20, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/remote_model.rb
View
@@ -107,18 +107,26 @@ def update_attributes(params = {})
end
end
- def methods
- methods = super
-
+ def remote_model_methods
+ methods = []
[self.class.has_one, self.class.has_many, self.class.belongs_to].each {|fn_hash|
methods += fn_hash.collect {|sym, klass|
[sym, (sym.to_s + "=:").to_sym]
}.flatten
}
+ methods + RemoteModule::RemoteModel::HTTP_METHODS
+ end
+
+ def methods
+ super + remote_model_methods
+ end
- methods += RemoteModule::RemoteModel::HTTP_METHODS
+ def respond_to?(symbol, include_private = false)
+ if remote_model_methods.include? symbol
+ return true
+ end
- methods
+ super
end
def method_missing(sym, *args, &block)

0 comments on commit 3fccd33

Please sign in to comment.