Sha256: bfc9330c48a121fd366330f49396e7628497982a5224ac37325c5e9d2e150292
Contents?: true
Size: 1.07 KB
Versions: 57
Compression:
Stored size: 1.07 KB
Contents
module Pfm module Generator # This is here to hold attr_accessor data for Generator context variables class Context def self.add_attr(name) @attributes ||= [] unless @attributes.include?(name) @attributes << name attr_accessor(name) end end def self.reset return if @attributes.nil? @attributes.each do |attr| remove_method(attr) end @attributes = nil end end def self.reset @context = nil end def self.context @context ||= Context.new end def self.add_attr_to_context(name, value = nil) sym_name = name.to_sym Pfm::Generator::Context.add_attr(sym_name) Pfm::Generator::TemplateHelper.delegate_to_app_context(sym_name) context.public_send("#{sym_name}=", value) end module TemplateHelper def self.delegate_to_app_context(name) define_method(name) do Pfm::Generator.context.public_send(name) end end def year Time.now.year end end end end
Version data entries
57 entries across 57 versions & 2 rubygems