Module: Mingle4r::CommonClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth_id, *args, &block) ⇒ Object (private)

Raises:



134
135
136
137
# File 'lib/mingle4r/common_class_methods.rb', line 134

def method_missing(meth_id, *args, &block)
  raise ResourceNotSetup.new("Site not set for #{name}.") unless @resource_class
  @resource_class.send(meth_id.to_sym, *args, &block)
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/mingle4r/common_class_methods.rb', line 5

def password
  @password
end

#siteObject

Returns the value of attribute site.



5
6
7
# File 'lib/mingle4r/common_class_methods.rb', line 5

def site
  @site
end

#userObject

Returns the value of attribute user.



5
6
7
# File 'lib/mingle4r/common_class_methods.rb', line 5

def user
  @user
end

Instance Method Details

#collection_nameObject

collection name for the class in which this module is extended



60
61
62
# File 'lib/mingle4r/common_class_methods.rb', line 60

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



44
45
46
47
48
49
# File 'lib/mingle4r/common_class_methods.rb', line 44

def collection_name=(collection_name)
  if collection_name != self.collection_name
    @collection_name = collection_name
  end
  @collection_name
end

#element_nameObject

element name for the class in which this module is extended



65
66
67
# File 'lib/mingle4r/common_class_methods.rb', line 65

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



52
53
54
55
56
57
# File 'lib/mingle4r/common_class_methods.rb', line 52

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



74
75
76
77
78
# File 'lib/mingle4r/common_class_methods.rb', line 74

def find(*args)
  scope = args.slice!(0)
  options = args.slice!(0) || {}
  @resource_class.find(scope, options)
end

#new(args = {}) ⇒ Object

creates an object of the class in which this module is extended



8
9
10
11
# File 'lib/mingle4r/common_class_methods.rb', line 8

def new(args = {})
  # @resource_class ||= create_resource_class() # should this be commented
  @resource_class.new(args)
end