Sha256: 8716d55403619a0c021533c2a012ed775a73801be6db29ed4e3aece08474ddf8

Contents?: true

Size: 815 Bytes

Versions: 29

Compression:

Stored size: 815 Bytes

Contents

# frozen-string-literal: true
module Mobility
  module Plugins
=begin

Defines convenience methods for accessing backends, of the form
"<name>_backend". The format for this method can be customized by passing a
different format string as the plugin option.

=end
    module BackendReader
      extend Plugin

      default true
      requires :backend

      initialize_hook do |*names|
        if backend_reader = options[:backend_reader]
          backend_reader = "%s_backend" if backend_reader == true

          names.each do |name|
            module_eval <<-EOM, __FILE__, __LINE__ + 1
            def #{backend_reader % name}
              mobility_backends[:#{name}]
            end
            EOM
          end
        end
      end
    end

    register_plugin(:backend_reader, BackendReader)
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
mobility-1.3.0.rc3 lib/mobility/plugins/backend_reader.rb
mobility-1.3.0.rc2 lib/mobility/plugins/backend_reader.rb
mobility-1.3.0.rc1 lib/mobility/plugins/backend_reader.rb
mobility-1.2.9 lib/mobility/plugins/backend_reader.rb
mobility-1.2.8 lib/mobility/plugins/backend_reader.rb
mobility-1.2.7 lib/mobility/plugins/backend_reader.rb
mobility-1.2.6 lib/mobility/plugins/backend_reader.rb
mobility-1.2.5 lib/mobility/plugins/backend_reader.rb
mobility-1.2.4 lib/mobility/plugins/backend_reader.rb
mobility-1.2.3 lib/mobility/plugins/backend_reader.rb
mobility-1.2.2 lib/mobility/plugins/backend_reader.rb
mobility-1.2.1 lib/mobility/plugins/backend_reader.rb
mobility-1.2.0 lib/mobility/plugins/backend_reader.rb
mobility-1.1.3 lib/mobility/plugins/backend_reader.rb
mobility-1.1.2 lib/mobility/plugins/backend_reader.rb
mobility-1.1.1 lib/mobility/plugins/backend_reader.rb
mobility-1.1.0 lib/mobility/plugins/backend_reader.rb
mobility-1.0.7 lib/mobility/plugins/backend_reader.rb
mobility-1.0.6 lib/mobility/plugins/backend_reader.rb
mobility-1.0.5 lib/mobility/plugins/backend_reader.rb