Module: Mobility::Backend::ConfiguredBackend
- Defined in:
- lib/mobility/backend.rb
Overview
Module included in configured backend classes, which in addition to methods on the parent backend class also have a model_class
and set of options
.
Class Method Summary collapse
Instance Method Summary collapse
- #inherited(_) ⇒ Object
-
#inspect ⇒ String
Show subclassed backend class name, if it has one.
-
#setup_model(model_class, attribute_names) ⇒ Object
Call setup block on a class with attributes and options.
Class Method Details
.build(backend_class, model_class, options) ⇒ Object
236 237 238 239 240 241 242 243 244 |
# File 'lib/mobility/backend.rb', line 236 def self.build(backend_class, model_class, ) Class.new(backend_class) do extend ConfiguredBackend @model_class = model_class configure() if respond_to?(:configure) @options = .freeze end end |
.extended(klass) ⇒ Object
246 247 248 |
# File 'lib/mobility/backend.rb', line 246 def self.extended(klass) klass.singleton_class.attr_reader :options, :model_class end |
Instance Method Details
#inherited(_) ⇒ Object
259 260 261 |
# File 'lib/mobility/backend.rb', line 259 def inherited(_) raise ConfiguredError, "Configured backends cannot be subclassed." end |
#inspect ⇒ String
Show subclassed backend class name, if it has one.
265 266 267 |
# File 'lib/mobility/backend.rb', line 265 def inspect (name = superclass.name) ? "#<#{name}>" : super end |
#setup_model(model_class, attribute_names) ⇒ Object
Call setup block on a class with attributes and options.
254 255 256 257 |
# File 'lib/mobility/backend.rb', line 254 def setup_model(model_class, attribute_names) return unless setup_block = @setup_block exec_setup_block(model_class, attribute_names, , self, &setup_block) end |