module Troles::Common::Config::Schema
Public Instance Methods
configure_field()
click to toggle source
configures a single main field on the subject fx if the roles are stored as a Boolean, Integer or String @note adapter should customize this as needed
# File lib/troles/common/config/schema.rb, line 29 def configure_field end
configure_generic()
click to toggle source
configures main field (fx role field) as a generic accessor
# File lib/troles/common/config/schema.rb, line 21 def configure_generic raise "Subject class must be a Class" unless subject_class.is_a?(Class) subject_class.send(:attr_accessor, main_field) # create troles accessor end
configure_models()
click to toggle source
configures the models if set to do so first configures
# File lib/troles/common/config/schema.rb, line 14 def configure_models configure_generic if generic? configure_field if auto_config?(:fields) configure_relation if auto_config?(:relations) end
configure_relation()
click to toggle source
configures model relationships for roles fx if the roles are stored in an model, either embedded or referenced @note adapter should customize this as needed
# File lib/troles/common/config/schema.rb, line 35 def configure_relation end
object_model()
click to toggle source
Gets the object model to be used see (object_model=
) see(default_object_model_class_name
)
@return [Class] the model class
# File lib/troles/common/config/schema.rb, line 52 def object_model @object_model_found ||= find_first_class(@object_model, default_object_model_class_name) end
Also aliased as: role_model
object_model=(model_class)
click to toggle source
Sets the object model to use allows different subject classes (fx User Accounts) to have different schemas @param [Class, String, Symbol] the model class
# File lib/troles/common/config/schema.rb, line 41 def object_model= model_class @object_model = model_class.to_s and return if model_class.any_kind_of?(Class, String, Symbol) raise "The object model must be a Class, was: #{model_class}" end
Also aliased as: role_mode=
Protected Instance Methods
default_object_model_class_name()
click to toggle source
# File lib/troles/common/config/schema.rb, line 59 def default_object_model_class_name 'Role' end