Module: Godfather

Defined in:
lib/godfather.rb,
lib/godfather/data.rb,
lib/godfather/manager.rb,
lib/godfather/version.rb

Defined Under Namespace

Classes: Data, Manager

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/godfather.rb', line 7

def self.included(base)
  base.send(:before_action, :init_crud, only: %i(where create update destroy))
end

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
# File 'lib/godfather.rb', line 17

def create
  record = @crud.create_from_data

  render json: {
    success: true,
    id: record.id,
  }
end

#destroyObject



35
36
37
38
39
40
41
# File 'lib/godfather.rb', line 35

def destroy
  @crud.destroy_from_data

  render json: {
    success: true,
  }
end

#updateObject



26
27
28
29
30
31
32
33
# File 'lib/godfather.rb', line 26

def update
  record = @crud.update_from_data

  render json: {
    success: true,
    id: record.id,
  }
end

#whereObject



11
12
13
14
15
# File 'lib/godfather.rb', line 11

def where
  records = @crud.find_scoped_records

  render json: serialized(records)
end