Sha256: 174d345ff5573c66d5727e496e360516080cb6307673e400259e1a1e90455c53

Contents?: true

Size: 1.04 KB

Versions: 35

Compression:

Stored size: 1.04 KB

Contents

module Lolita
  module Configuration
    # This is superclass of other configuration classes, that is used to configure different parts of resource. 
    class Base
      include Lolita::Builder
      attr_reader :dbi
      attr_writer :component
      alias :dbp :dbi

      def initialize(dbp, *args)
        set_and_validate_dbp dbp
        set_attributes *args
      end

      def component
        @component ||= "Lolita::Components::#{self.class.to_s.sub("Lolita::","")}Component".constantize.new(self)
      end

      private

      def set_and_validate_dbp(dbp)
        @dbp = dbp
        @dbi = dbp
        raise Lolita::UnknownDBPError.new("No DBP specified for #{self.class.to_s.split("::").last}") unless @dbp
      end

      alias :set_and_validate_dbi :set_and_validate_dbp

      # Used to set attributes if block not given.
      def set_attributes(*args)
        options = args && args.extract_options! || {}
        options.each do |attr_name,value|
          self.send("#{attr_name}=".to_sym,value)
        end
      end

    end

  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
lolita-4.0.11 lib/lolita/configuration/base.rb
lolita-4.0.10 lib/lolita/configuration/base.rb
lolita-4.0.9 lib/lolita/configuration/base.rb
lolita-4.0.8 lib/lolita/configuration/base.rb
lolita-4.0.7 lib/lolita/configuration/base.rb
lolita-4.0.6 lib/lolita/configuration/base.rb
lolita-4.0.5 lib/lolita/configuration/base.rb
lolita-4.0.4 lib/lolita/configuration/base.rb
lolita-4.0.3 lib/lolita/configuration/base.rb
lolita-4.0.2 lib/lolita/configuration/base.rb
lolita-4.0.1 lib/lolita/configuration/base.rb
lolita-4.0.0 lib/lolita/configuration/base.rb
lolita-3.4.3 lib/lolita/configuration/base.rb
lolita-3.4.2 lib/lolita/configuration/base.rb
lolita-3.4.1 lib/lolita/configuration/base.rb
lolita-3.4.0 lib/lolita/configuration/base.rb
lolita-3.3.9 lib/lolita/configuration/base.rb
lolita-3.3.8 lib/lolita/configuration/base.rb
lolita-3.3.7 lib/lolita/configuration/base.rb
lolita-3.3.6 lib/lolita/configuration/base.rb