Sha256: 51ae579d084b3db20dd85316c16bcdf1c3dda69ede16cfef66790f37c62881c6
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
class Array def to_params join('&').to_params end end class Class def inherited_property(accessor, default = nil) instance_eval <<-RUBY, __FILE__, __LINE__ + 1 @#{accessor} = default def set_#{accessor}(value) @#{accessor} = value end alias #{accessor} set_#{accessor} def get_#{accessor} return @#{accessor} if instance_variable_defined?(:@#{accessor}) superclass.send(:#{accessor}) end RUBY # @path = default # # def set_path(value) # @path = value # end # alias_method path, set_path # def get_path # return @path if instance_variable_defined?(:path) # superclass.send(:path) # end end def inherited_accessor(accessor, default = nil) instance_eval <<-RUBY, __FILE__, __LINE__ + 1 class << self; attr_writer :#{accessor}; end @#{accessor} = default def #{accessor} return @#{accessor} if instance_variable_defined?(:@#{accessor}) superclass.send(:#{accessor}) end RUBY end end class Hash def to_params map { |k, v| if v.instance_of?(Hash) v.map { |sk, sv| "#{k}[#{sk}]=#{sv}" }.join('&') else "#{k}=#{v}" end }.join('&').to_params end end class NilClass def to_params '' end end class String def to_params URI.escape(self, /[^-_.!~*'()a-zA-Z\d;\/?@&=+$,\[\]]/n) # Escape colons end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
primedia-endeca-0.9.17 | lib/core_ext.rb |