Module: Roy::ClassMethods

Defined in:
lib/roy/base.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) conf (readonly)

Returns the value of attribute conf



48
49
50
# File 'lib/roy/base.rb', line 48

def conf
  @conf
end

Class Method Details

+ (Object) extended(base)

Setup default configuration for the application.



51
52
53
54
55
56
# File 'lib/roy/base.rb', line 51

def self.extended(base)
  base.instance_eval do
    @conf ||= OpenStruct.new
    roy Defaults
  end
end

Instance Method Details

- (Object) roy(options = {})

Set options for the application



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/roy/base.rb', line 59

def roy(options={})
  options.each do |key,value|
    case key
    when :allow
      (conf.allow ||= Set.new).merge(value)
      conf.allow.add(:head) if value.member?(:get)
    when :use
      value.each do |name|
        if name.is_a?(Symbol)
          require "roy/#{name}"
          const = "#{name}".capitalize.gsub(/_(\w)/) {|m| m[1].upcase }.to_sym
          name = Roy.const_get(const)
        end
        include name
      end
    else
      conf.send(:#{key}=", value)
    end
  end
end