Method: ApiResource::Base.prefix=

Defined in:
lib/api_resource/base.rb

.prefix=(value = '/') ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/api_resource/base.rb', line 129

def prefix=(value = '/')
  prefix_call = value.gsub(/:\w+/) { |key| "\#{URI.escape options[#{key}].to_s}"}
  @prefix_parameters = nil
  silence_warnings do
    instance_eval <<-EOE, __FILE__, __LINE__ + 1
      def prefix_source() "#{value}" end
      def prefix(options={}) "#{prefix_call}" end
    EOE
  end
rescue Exception => e
  logger.error "Couldn't set prefix: #{e}\n #{code}" if logger
  raise
end