Sha256: 8937f04f956f8d95d2ee84c007f67789b7ce1de0fc61f6f1eb5697dd88b1e66a

Contents?: true

Size: 846 Bytes

Versions: 2

Compression:

Stored size: 846 Bytes

Contents

module Susply
  class InstallGenerator < Rails::Generators::Base
    source_root File.expand_path("../../templates", __FILE__)

    argument :subscription_owner_model, :type => :string, :required => true, 
      :desc => "Owner of the subscription"

    def subscription_owner_model
      @subscription_owner_model.capitalize
    end

    def billable_entity
      @subscription_owner_model.downcase
    end

    def install
      template "config/initializers/susply.rb"

      inject_into_class "app/models/#{subscription_owner_model.downcase}.rb", 
        subscription_owner_model.downcase.camelize.constantize,
        "# Added by Susply\n  include Susply::OwnerMethods  \n\n"

      copy_locales
    end

    def copy_locales
      copy_file "../../../config/locales/susply.en.yml",
        "config/locales/susply.en.yml"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
susply-1.0.0 lib/generators/susply/install_generator.rb
susply-0.0.2 lib/generators/susply/install_generator.rb