Class: Editus::Configuration

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

Constant Summary collapse

CONFIG_PATH =
"config/editus.yml"
CONFIG_KEYS =
%w[models auth actions_file_path]
INITIALIZER_FILE_PATH =
"config/initializers/editus.rb"

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



20
21
22
23
24
25
# File 'lib/editus.rb', line 20

def initialize
  @table = {
    models: [],
    actions_file_path: "tmp/editus/actions.json"
  }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mid, *args) ⇒ Object (private)



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

def method_missing mid, *args
  len = args.length
  mname = mid[/.*(?==\z)/m]
  if mname
    if len != 1
      raise ArgumentError, "wrong number of arguments (given #{len}, expected 1)", caller(1)
    end

    @table[mname.to_sym] = args[0]
  elsif len.zero?
    @table[mid]
  else
    begin
      super
    rescue NoMethodError => e
      e.backtrace.shift
      raise
    end
  end
end

Instance Method Details

#[](name) ⇒ Object



27
28
29
# File 'lib/editus.rb', line 27

def [] name
  @table[name.to_sym]
end

#[]=(name, value) ⇒ Object



31
32
33
34
# File 'lib/editus.rb', line 31

def []= name, value
  name = name.to_sym
  @table[name] = value
end