Module: Ymodel::Helper

Defined in:
lib/ymodel/helper.rb

Overview

This module contains YModel logic for managing relations.

Class Method Summary collapse

Class Method Details

.model_class(model) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/ymodel/helper.rb', line 6

def self.model_class(model)
  as_const = model.to_s.singularize.camelcase
  Kernel.const_get(as_const)
rescue StandardError
  message = "relation `#{model}` couldn't be made because constant "\
            "`#{as_const}` doesn't exist."
  raise Ymodel::MissingConstant, message
end