Sha256: f6f2935707051db32fdc72cdf96f027dd10e1a932cac12b9bc92b06907bc0c62

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

module CanTango
  module Generators
    module PermitGenerator

      def template_permit role, account = nil
        template_account_permit role, account if account
        template permit_source, "app/permits/#{permit_target(role)}" unless account
      end

      def template_account_permit role, account
        template "account_permit.erb" , "app/permits/#{account}_permits/#{permit_target(role)}"
      end

      def load_permit_template name
        template = ERB.new File.open(template_filepath).read
        template.result(binding)
      end

      def template_filepath
        File.join source_path, permit_source
      end

      def source_path
        source_paths.first
      end

      def permit_source
        group? ? "role_group_permit.erb" : "role_permit.erb"
      end

      def permit_target role
        group? ? "#{role}_group_permit.rb" : "#{role}_permit.rb"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-0.8.0 lib/generators/cantango/permit_generator.rb