Class: DealsWith::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/deals_with/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={}, &scope_proc)
  @controller_class = controller_class
  @model_name = model_name.to_s.classify
  @options    = options
  @scope_proc = scope_proc
end

Instance Attribute Details

#model_nameObject (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

Returns:

  • (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