class DeepStore::Model::KeyFactory
Attributes
resource[R]
Public Class Methods
call(*args)
click to toggle source
# File lib/deep_store/model/key_factory.rb, line 4 def self.call(*args) new.call(*args) end
Public Instance Methods
call(resource, pattern)
click to toggle source
# File lib/deep_store/model/key_factory.rb, line 8 def call(resource, pattern) @resource = resource key = pattern.gsub(/\:(\w+)/) { |m| process_match(m) } key end
Private Instance Methods
process_match(match)
click to toggle source
# File lib/deep_store/model/key_factory.rb, line 18 def process_match(match) attribute = match[1..-1] return unless resource.respond_to?(attribute) value = resource.send(attribute) return match unless value value end