Sha256: 22743ea195f022bdbbcfa509d349476a28e8ae90cdbb051bbc4aa52f32c38b74
Contents?: true
Size: 759 Bytes
Versions: 7
Compression:
Stored size: 759 Bytes
Contents
class String def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end module Eventbrite module Api module Helpers def model(model_name) method_name = model_name.to_s.underscore variable_name = "@#{method_name}_model".to_sym unless instance_variable_defined?(variable_name) instance_variable_set(variable_name, Eventbrite::Api::Model.const_get("#{model_name}".to_sym).new(self, model_name.to_s)) self.define_singleton_method(method_name.to_sym) do instance_variable_get(variable_name) end end instance_variable_get(variable_name) end end end end
Version data entries
7 entries across 7 versions & 2 rubygems