Module: Roy::ClassMethods
- Defined in:
- lib/roy/base.rb
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
Class Method Summary collapse
-
.extended(base) ⇒ Object
Setup default configuration for the application.
Instance Method Summary collapse
-
#roy(options = {}) ⇒ Object
Set options for the application.
Instance Attribute Details
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
48 49 50 |
# File 'lib/roy/base.rb', line 48 def conf @conf end |
Class Method Details
.extended(base) ⇒ Object
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
#roy(options = {}) ⇒ Object
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(={}) .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 |