class Dry::Generators::MonadGenerator

Public Instance Methods

check_requirements() click to toggle source
# File lib/generators/dry/monad/monad_generator.rb, line 8
def check_requirements
  raise 'NAME must be provided' unless file_name.present?
end
copy_monad() click to toggle source
# File lib/generators/dry/monad/monad_generator.rb, line 17
def copy_monad
  path = File.join(MONADS_PATH, "#{@name}.rb")
  template 'monad_template.rb', path
end
copy_spec() click to toggle source
# File lib/generators/dry/monad/monad_generator.rb, line 22
def copy_spec
  if Dir.exist? File.join(Rails.root, 'spec')
    spec_path =  File.join(SPEC_PATH, 'monads')
    path = File.join(spec_path, "#{@name}_spec.rb")
    template 'monad_spec_template.rb', path
  end
end
copy_test() click to toggle source
# File lib/generators/dry/monad/monad_generator.rb, line 30
def copy_test
  if Dir.exist? File.join(Rails.root, 'test')
    test_path =  File.join(TEST_PATH, 'monads')
    path = File.join(test_path, "#{@name}_test.rb")
    template 'monad_test_template.rb', path
  end
end
set_instance_variables() click to toggle source
# File lib/generators/dry/monad/monad_generator.rb, line 12
def set_instance_variables
  @name = file_name.underscore
  @class_name = "#{@name.camelize}"
end