Sha256: 870397d9c631e8e5c143482643b58385670f05f9e860b1696775a7e4fed76a96
Contents?: true
Size: 455 Bytes
Versions: 5
Compression:
Stored size: 455 Bytes
Contents
module BluepanClient class ApplyVars include Virtus.model attribute :string, String attribute :object, Object def self.call(string, object) self.new(string: string, object: object).() end def call matches = string.scan(/:\w+/) matches.reduce(string) do |str, var| method_name = var.gsub(":", "") value = object.send(method_name) str.gsub(var, value.to_s) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems