Class: DealsWith::Resource
- Inherits:
-
Object
- Object
- DealsWith::Resource
- Defined in:
- lib/deals_with/resource.rb
Instance Attribute Summary collapse
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Instance Method Summary collapse
-
#all(controller) ⇒ Object
searchers.
- #build(controller) ⇒ Object
- #can_find?(controller) ⇒ Boolean
- #find(controller) ⇒ Object
-
#initialize(controller_class, model_name, options = {}, &scope_proc) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(controller_class, model_name, options = {}, &scope_proc) ⇒ Resource
Returns a new instance of Resource.
14 15 16 17 18 19 |
# File 'lib/deals_with/resource.rb', line 14 def initialize(controller_class, model_name, ={}, &scope_proc) @controller_class = controller_class @model_name = model_name.to_s.classify @options = @scope_proc = scope_proc end |
Instance Attribute Details
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
6 7 8 |
# File 'lib/deals_with/resource.rb', line 6 def model_name @model_name end |
Instance Method Details
#all(controller) ⇒ Object
searchers
88 89 90 |
# File 'lib/deals_with/resource.rb', line 88 def all(controller) base(controller).all end |
#build(controller) ⇒ Object
96 97 98 |
# File 'lib/deals_with/resource.rb', line 96 def build(controller) base(controller).build(build_param(controller)) end |
#can_find?(controller) ⇒ Boolean
82 83 84 |
# File 'lib/deals_with/resource.rb', line 82 def can_find?(controller) !find_param(controller).blank? end |
#find(controller) ⇒ Object
92 93 94 |
# File 'lib/deals_with/resource.rb', line 92 def find(controller) base(controller).find(find_param(controller)) end |