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
  @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



93
94
95
# File 'lib/deals_with/resource.rb', line 93

def all(controller)
  base(controller).all
end

#build(controller) ⇒ Object



101
102
103
# File 'lib/deals_with/resource.rb', line 101

def build(controller)
  base(controller).build(build_param(controller))
end

#can_find?(controller) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/deals_with/resource.rb', line 87

def can_find?(controller)
  !find_param(controller).blank?
end

#find(controller) ⇒ Object



97
98
99
# File 'lib/deals_with/resource.rb', line 97

def find(controller)
  base(controller).find(find_param(controller))
end