Module: Databound
- Defined in:
- lib/databound.rb,
lib/databound/data.rb,
lib/databound/manager.rb,
lib/databound/version.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Data, Manager, NotPermittedError
Constant Summary
collapse
- VERSION =
'0.0.3'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
9
10
11
12
|
# File 'lib/databound.rb', line 9
def self.included(base)
base.send(:before_action, :init_crud, only: i(where create update destroy))
base.extend(ClassMethods)
end
|
Instance Method Details
#create ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/databound.rb', line 20
def create
record = @crud.create_from_data
render json: {
success: true,
id: record.id,
}
end
|
#destroy ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/databound.rb', line 38
def destroy
@crud.destroy_from_data
render json: {
success: true,
}
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/databound.rb', line 29
def update
record = @crud.update_from_data
render json: {
success: true,
id: record.id,
}
end
|
#where ⇒ Object
14
15
16
17
18
|
# File 'lib/databound.rb', line 14
def where
records = @crud.find_scoped_records
render json: serialized(records)
end
|