class Godmin::Generators::Base
Public Class Methods
source_paths()
click to toggle source
# File lib/godmin/generators/base.rb, line 6 def self.source_paths %w[authentication install policy resource].map do |path| File.expand_path("../../../generators/godmin/#{path}/templates", __FILE__) end end
Private Instance Methods
indent(content, multiplier = 2)
click to toggle source
# File lib/godmin/generators/base.rb, line 38 def indent(content, multiplier = 2) spaces = " " * multiplier content.each_line.map { |line| line.blank? ? line : "#{spaces}#{line}" }.join end
module_namespacing(&block)
click to toggle source
# File lib/godmin/generators/base.rb, line 32 def module_namespacing(&block) content = capture(&block) content = wrap_with_namespace(content) if namespaced? concat(content) end
namespace()
click to toggle source
# File lib/godmin/generators/base.rb, line 14 def namespace @_namespace ||= Rails::Generators.namespace end
namespaced?()
click to toggle source
# File lib/godmin/generators/base.rb, line 18 def namespaced? @_namespaced ||= namespace.present? end
namespaced_path()
click to toggle source
# File lib/godmin/generators/base.rb, line 22 def namespaced_path @_namespaced_path ||= begin if namespaced? namespace.name.split("::").map(&:underscore) else [] end end end
wrap_with_namespace(content)
click to toggle source
# File lib/godmin/generators/base.rb, line 43 def wrap_with_namespace(content) content = indent(content).chomp "module #{namespace.name}\n#{content}\nend\n" end