Module: CouchRest::Model::Configuration::ClassMethods

Defined in:
lib/couchrest/model/configuration.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_config(name)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/couchrest/model/configuration.rb', line 42

def add_config(name)
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
    def self.#{name}(value=nil)
      @#{name} = value if value
      return @#{name} if self.object_id == #{self.object_id} || defined?(@#{name})
      name = superclass.#{name}
      return nil if name.nil? && !instance_variable_defined?("@#{name}")
      @#{name} = name && !name.is_a?(Module) && !name.is_a?(Symbol) && !name.is_a?(Numeric) && !name.is_a?(TrueClass) && !name.is_a?(FalseClass) ? name.dup : name
    end

    def self.#{name}=(value)
      @#{name} = value
    end

    def #{name}
      self.class.#{name}
    end
  RUBY
end

- (Object) configure {|_self| ... }

Yields:

  • (_self)

Yield Parameters:



62
63
64
# File 'lib/couchrest/model/configuration.rb', line 62

def configure
  yield self
end