Sha256: ae5f0b057009fe1157c9aa5f5dea34a9a4d9eb61ef7f511f54211c224790d22d

Contents?: true

Size: 642 Bytes

Versions: 4

Compression:

Stored size: 642 Bytes

Contents

class Gator
  module ActAsConfiguration

    def add_getter name, val
      self.class.send :attr_reader, name
      instance_variable_set "@#{name}", val
    end

    def add_configuration(name, val=nil)

      create_method "#{name.to_s}=" do |val|
        instance_variable_set("@#{name}", val)
      end

      create_method name do |&block|
        block.call(instance_variable_get("@#{name}")) if block
        instance_variable_get("@#{name}")
      end

      instance_variable_set("@#{name}", val) if val
    end

    private

    def create_method(name, &block)
      self.class.send(:define_method, name, &block)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gator-0.0.25.pre lib/gator/core/configuration/act_as_configuration.rb
gator-0.0.24.pre lib/gator/core/configuration/act_as_configuration.rb
gator-0.0.23.pre lib/gator/core/configuration/act_as_configuration.rb
gator-0.0.22.pre lib/gator/core/configuration/act_as_configuration.rb