Module: Kiqr::Models
- Defined in:
- lib/kiqr.rb,
lib/kiqr/models.rb,
lib/kiqr/models/user.rb,
lib/kiqr/models/member.rb,
lib/kiqr/models/account.rb,
lib/kiqr/models/omniauth_identity.rb
Defined Under Namespace
Modules: Account, Member, OmniauthIdentity, User
Constant Summary collapse
- AVAILABLE_MODELS =
%w[account member omniauth_identity user].freeze
Instance Method Summary collapse
-
#kiqr(model:) ⇒ Object
This will allow us to use the kiqr method in the models to include the appropriate module for the specific model.
Instance Method Details
#kiqr(model:) ⇒ Object
This will allow us to use the kiqr method in the models to include the appropriate module for the specific model.
Example: class User < ApplicationRecord
kiqr model: :user
end
12 13 14 15 16 17 |
# File 'lib/kiqr/models.rb', line 12 def kiqr(model:) raise ArgumentError, "Invalid model: #{model}" unless AVAILABLE_MODELS.include?(model.to_s) klass_name = model.to_s.camelize include Kiqr::Models.const_get(klass_name) end |