Class: Pulitzer::ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/pulitzer/application_record.rb

Class Method Summary collapse

Class Method Details

.assoc_nameObject



4
5
6
# File 'app/models/pulitzer/application_record.rb', line 4

def self.assoc_name
  @assoc_name ||= name.demodulize.underscore.pluralize
end

.attrs_nameObject



8
9
10
# File 'app/models/pulitzer/application_record.rb', line 8

def self.attrs_name
  @attrs_name ||= assoc_name + '_attributes'
end

.convert_hash_to_nested(json_hash) ⇒ Object



12
13
14
15
16
17
18
# File 'app/models/pulitzer/application_record.rb', line 12

def self.convert_hash_to_nested(json_hash)
  if json_hash.has_key? assoc_name
    json_hash[attrs_name] = json_hash[assoc_name]
    json_hash.delete assoc_name
  end
  convert_nested_assoc json_hash
end

.convert_nested_assoc(json_hash) ⇒ Object



20
21
22
# File 'app/models/pulitzer/application_record.rb', line 20

def self.convert_nested_assoc(json_hash)
  json_hash
end