Module: DynamicActiveResource::CommonClassMethods
- Defined in:
- lib/dynamic_active_resource/common_class_methods.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#site ⇒ Object
Returns the value of attribute site.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#collection_name ⇒ Object
collection name for the class in which this module is extended.
-
#collection_name=(collection_name) ⇒ Object
sets the collection name for the class in which this module is extended.
-
#element_name ⇒ Object
element name for the class in which this module is extended.
-
#element_name=(element_name) ⇒ Object
sets the elment name for the class in which this module is extended.
-
#find(*args) ⇒ Object
routes to active resource find.
-
#new(args = {}) ⇒ Object
creates an object of the class in which this module is extended.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth_id, *args, &block) ⇒ Object (private)
127 128 129 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 127 def method_missing(meth_id, *args, &block) @resource_class.send(meth_id, *args, &block) end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 3 def password @password end |
#site ⇒ Object
Returns the value of attribute site.
3 4 5 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 3 def site @site end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 3 def user @user end |
Instance Method Details
#collection_name ⇒ Object
collection name for the class in which this module is extended
58 59 60 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 58 def collection_name @collection_name || class_name.underscore.pluralize end |
#collection_name=(collection_name) ⇒ Object
sets the collection name for the class in which this module is extended
42 43 44 45 46 47 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 42 def collection_name=(collection_name) if collection_name != self.collection_name @collection_name = collection_name end @collection_name end |
#element_name ⇒ Object
element name for the class in which this module is extended
63 64 65 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 63 def element_name @element_name || class_name.underscore end |
#element_name=(element_name) ⇒ Object
sets the elment name for the class in which this module is extended
50 51 52 53 54 55 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 50 def element_name=(element_name) if element_name != self.element_name @element_name = element_name end @element_name end |
#find(*args) ⇒ Object
routes to active resource find
68 69 70 71 72 73 74 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 68 def find(*args) return @resource_class.find_without_pagination(*args) if(@resource_class.respond_to?(:find_without_pagination)) scope = args.slice!(0) = args.slice!(0) || {} obj = @resource_class.find(scope, ) obj end |
#new(args = {}) ⇒ Object
creates an object of the class in which this module is extended
6 7 8 9 |
# File 'lib/dynamic_active_resource/common_class_methods.rb', line 6 def new(args = {}) # @resource_class = create_resource_class() # should this be commented @resource_class.new(args) end |