Sha256: 0981d355361615e5905be6f474ed8518e114f7cf62478951e1ec8b871470fb0b

Contents?: true

Size: 1.3 KB

Versions: 20

Compression:

Stored size: 1.3 KB

Contents

module Mobility
=begin

Plugins allow modular customization of backends independent of the backend
itself. They are enabled through the {Configuration.plugins} configuration
setting, which takes an array of symbols corresponding to plugin names. The
order of these names is important since it determines the order in which
plugins will be applied.

So if our {Configuration.plugins} is an array +[:foo]+, and we call
`translates` on our model, +Post+, like this:

  class Post
    translates :title, foo: true
  end

Then the +Foo+ plugin will be applied with the option value +true+. Applying a
module calls a class method, +apply+ (in this case +Foo.apply+), which takes
two arguments:

- an instance of the {Attributes} class, +attributes+, from which the backend
  can configure the backend class (+attributes.backend_class+) and the model
  (+attributes.model_class+), and the +attributes+ module itself (which
  will be included into the backend).
- the value of the +option+ passed into the model with +translates+ (in this
  case, +true+).

Typically, the plugin will include a module into either
+attributes.backend_class+ or +attributes+ itself, configured according to the
option value. For examples, see classes under the {Mobility::Plugins} namespace.

=end
  module Plugins
    OPTION_UNSET = Object.new
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mobility-0.8.13 lib/mobility/plugins.rb
mobility-0.8.11 lib/mobility/plugins.rb
mobility-0.8.10 lib/mobility/plugins.rb
mobility-0.8.9 lib/mobility/plugins.rb
mobility-0.8.8 lib/mobility/plugins.rb
mobility-0.8.7 lib/mobility/plugins.rb
mobility-0.8.6 lib/mobility/plugins.rb
mobility-0.8.5 lib/mobility/plugins.rb
mobility-0.8.4 lib/mobility/plugins.rb
mobility-0.8.3 lib/mobility/plugins.rb
mobility-0.8.2 lib/mobility/plugins.rb
mobility-0.8.1 lib/mobility/plugins.rb
mobility-0.8.0 lib/mobility/plugins.rb
mobility-0.7.6 lib/mobility/plugins.rb
mobility-0.7.5 lib/mobility/plugins.rb
mobility-0.7.4 lib/mobility/plugins.rb
mobility-0.7.3 lib/mobility/plugins.rb
mobility-0.7.2 lib/mobility/plugins.rb
mobility-0.7.1 lib/mobility/plugins.rb
mobility-0.7.0 lib/mobility/plugins.rb