Module: OurKudos::Api::Controllers::ApiHelper

Included in:
ClientBase
Defined in:
lib/ourkudos/controllers/api_helper.rb

Instance Method Summary collapse

Instance Method Details

#api_columns(*skipped) ⇒ Object



11
12
13
14
15
16
# File 'lib/ourkudos/controllers/api_helper.rb', line 11

def api_columns *skipped
  current_model.column_names.select do |c|
    !c.include?("_id") && !c.include?("_by") &&
      !c.include?("_at") && !skipped.include?(c)
 end
end

#current_modelObject



7
8
9
# File 'lib/ourkudos/controllers/api_helper.rb', line 7

def current_model
  @current_model ||= Kernel.const_get controller_name.singularize.classify
end

#model_as_symbolObject



18
19
20
# File 'lib/ourkudos/controllers/api_helper.rb', line 18

def model_as_symbol
  controller_name.singularize.to_sym
end

#model_instanceObject



22
23
24
# File 'lib/ourkudos/controllers/api_helper.rb', line 22

def model_instance
  instance_variable_get "@#{controller_name.singularize}"
end