Module: ActsAsElementInCategory::Element::ClassMethods
- Defined in:
- lib/acts_as_element_in_category/element.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/acts_as_element_in_category/element.rb', line 19
def method_missing(method_name, *args)
if /^acts_as_element_in_(?<category_name>.+)$/ =~ method_name
return acts_as_element_in(category_name.to_sym, *args)
end
self
end
|
Instance Method Details
#acts_as_element_in(category_name, options = {}) ⇒ Object
10
11
12
13
|
# File 'lib/acts_as_element_in_category/element.rb', line 10
def acts_as_element_in(category_name, options={})
@category_column = category_name.to_s
belongs_to category_name, options
end
|
#in(category, *args) ⇒ Object
15
16
17
|
# File 'lib/acts_as_element_in_category/element.rb', line 15
def in(category, *args)
where("#{@category_column}_id = ?", category.id)
end
|