Module: Pathway::Plugins::SequelModels::ClassMethods
- Defined in:
- lib/pathway/plugins/sequel_models.rb
Instance Attribute Summary collapse
-
#model_class ⇒ Object
Returns the value of attribute model_class.
-
#model_not_found ⇒ Object
Returns the value of attribute model_not_found.
-
#search_field ⇒ Object
Returns the value of attribute search_field.
Instance Method Summary collapse
- #inherited(subclass) ⇒ Object
- #model(model_class, search_by: model_class.primary_key, set_result_key: true, set_context_param: true, error_message: nil) ⇒ Object
Instance Attribute Details
#model_class ⇒ Object
Returns the value of attribute model_class.
41 42 43 |
# File 'lib/pathway/plugins/sequel_models.rb', line 41 def model_class @model_class end |
#model_not_found ⇒ Object
Returns the value of attribute model_not_found.
41 42 43 |
# File 'lib/pathway/plugins/sequel_models.rb', line 41 def model_not_found @model_not_found end |
#search_field ⇒ Object
Returns the value of attribute search_field.
41 42 43 |
# File 'lib/pathway/plugins/sequel_models.rb', line 41 def search_field @search_field end |
Instance Method Details
#inherited(subclass) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/pathway/plugins/sequel_models.rb', line 52 def inherited(subclass) super subclass.model_class = model_class subclass.search_field = search_field subclass.model_not_found = model_not_found end |
#model(model_class, search_by: model_class.primary_key, set_result_key: true, set_context_param: true, error_message: nil) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/pathway/plugins/sequel_models.rb', line 43 def model(model_class, search_by: model_class.primary_key, set_result_key: true, set_context_param: true, error_message: nil) self.model_class = model_class self.search_field = search_by self.result_key = Inflector.underscore(Inflector.demodulize(model_class.name)).to_sym if set_result_key self.model_not_found = || "#{Inflector.humanize(Inflector.underscore(Inflector.demodulize(model_class.name)))} not found".freeze self.context(result_key => Contextualizer::OPTIONAL) if set_result_key && set_context_param end |