Method: ActiveResource::Base.prefix=
- Defined in:
- lib/active_resource/base.rb
.prefix=(value = "/") ⇒ Object Also known as: set_prefix
Sets the prefix for a resource’s nested URL (e.g., prefix/collectionname/1.json). Default value is site.path.
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
# File 'lib/active_resource/base.rb', line 751 def prefix=(value = "/") # Replace :placeholders with '#{embedded options[:lookups]}' prefix_call = value.gsub(/:\w+/) { |key| "\#{URI::DEFAULT_PARSER.escape options[#{key}].to_s}" } # Clear prefix parameters in case they have been cached @prefix_parameters = nil silence_warnings do # Redefine the new methods. instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def prefix_source() "#{value}" end def prefix(options={}) "#{prefix_call}" end RUBY_EVAL end rescue Exception => e logger.error "Couldn't set prefix: #{e}\n #{code}" if logger raise end |