Sha256: 22986e9a3e2954323ed9e153bced16caab58337934fd9b34e485e40e65f43616
Contents?: true
Size: 760 Bytes
Versions: 6
Compression:
Stored size: 760 Bytes
Contents
module Catche class ResourceLoader class << self # Fetches resources in the given context, for example a controller # # Catche::Tag::ResourceLoader.fetch(controller, :task) def fetch(context, *names) names.collect do |name| if resource = context.instance_variable_get("@#{name}") resource elsif context.respond_to?(name) begin context.send(name) rescue nil end else nil end end.compact end def fetch_one(context, name) fetch(context, name).first end def exists?(context, name) fetch_one(context, name).present? end end end end
Version data entries
6 entries across 6 versions & 1 rubygems