Module: GlTail::Configurable::ClassMethods

Defined in:
lib/gl_tail/config/configurable.rb

Instance Method Summary collapse

Instance Method Details

#config_attribute(id, description = "", opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gl_tail/config/configurable.rb', line 6

def config_attribute(id, description = "", opts = {})

  rewrite_method = case opts[:type]
  when :color
    "config_rewrite_color"
  else
    ""
  end

  self.class_eval %{
    def #{id}=(value)
      @#{id} = #{rewrite_method} value
    end

    def #{id}
      @#{id}
    end
  }

  doc = GlTail::CONFIG_OPTIONS[self.to_s] ||= {}
  doc[id] = {
    :description => description,
  }.update(opts)        
end