Sha256: e3e115fa26e74a9128d2d74996fe28264f74f66d6b4f49a4d44c34599ae32575
Contents?: true
Size: 713 Bytes
Versions: 3
Compression:
Stored size: 713 Bytes
Contents
module Catche module Tag class Resource class << self def pluralize(object) object.name.to_s.pluralize.downcase end def singularize(object) object.name.to_s.singularize.downcase end def resource(object, name) if resource = object.instance_variable_get("@#{name}") return resource elsif object.respond_to?(name) begin return object.send(name) rescue; end end nil end def associations(object, associations) associations.map { |association| resource(object, association) }.compact end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
catche-0.1.2 | lib/catche/tag/resource.rb |
catche-0.1.1 | lib/catche/tag/resource.rb |
catche-0.1.0 | lib/catche/tag/resource.rb |