Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/god.rb

Instance Method Summary collapse

Instance Method Details

#safe_attr_accessor(*args) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/god.rb', line 125

def safe_attr_accessor(*args)
  args.each do |arg|
    define_method(:"#{arg}=") do |other|
      abort "God.#{arg} must be set before any Tasks are defined" if !running && inited

      if running && inited
        applog(nil, :warn, "God.#{arg} can't be set while god is running")
        return
      end

      instance_variable_set(:"@#{arg}", other)
    end

    define_method(arg) do
      instance_variable_get(:"@#{arg}")
    end
  end
end