Sha256: 83551fdbf43aa9ed8ac6f48c6d6b36f465e5d728163f29e0423f629b56b4c17b
Contents?: true
Size: 785 Bytes
Versions: 1
Compression:
Stored size: 785 Bytes
Contents
module Microscope class InstanceMethod < Struct.new(:model, :field) # Inject ActiveRecord scopes into a model def self.inject_instance_methods(model, fields, options = {}) fields.each do |field| scope = "#{field.type.to_s.camelize}InstanceMethod" if Microscope::InstanceMethod.const_defined?(scope) "Microscope::InstanceMethod::#{scope}".constantize.new(model, field).apply end end end # Convert a past participle to its infinitive form def self.past_participle_to_infinitive(participle) if Microscope.irregular_verbs.include?(participle) Microscope.irregular_verbs[participle] elsif participle =~ /ed$/ participle.sub(/d$/, '') else participle end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
microscope-0.5.2 | lib/microscope/instance_method.rb |