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