Module: Adauth::Rails::ModelBridge::ClassMethods

Defined in:
lib/adauth/rails/model_bridge.rb

Overview

Class Methods for ModelBridge

Instance Method Summary collapse

Instance Method Details

#create_from_adauth(adauth_model) ⇒ Object

Creates a new RailsModel from the adauth_model



46
47
48
49
# File 'lib/adauth/rails/model_bridge.rb', line 46

def create_from_adauth(adauth_model)
    rails_model = self.new
    rails_model.update_from_adauth(adauth_model)
end

#return_and_create_from_adauth(adauth_model) ⇒ Object

Used to create the RailsModel if it doesn’t exist and update it if it does



52
53
54
55
56
57
# File 'lib/adauth/rails/model_bridge.rb', line 52

def return_and_create_from_adauth(adauth_model)
    find_method = "find_by_#{self::AdauthSearchField.last}".to_sym
    rails_model = (self.send(find_method, adauth_model.send(self::AdauthSearchField.first)) || create_from_adauth(adauth_model))
    rails_model.update_from_adauth(adauth_model)
    return rails_model
end