Class: Dev::Template::BaseInterface

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/firespring_dev_commands/templates/base_interface.rb

Overview

Base interface template takes a custom arg for the initializer and requires the user to implement the create_tasks! method

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exclude: []) ⇒ BaseInterface

Returns a new instance of BaseInterface.



12
13
14
15
# File 'lib/firespring_dev_commands/templates/base_interface.rb', line 12

def initialize(exclude: [])
  @exclude = Array(exclude).map(&:to_sym)
  create_tasks!
end

Instance Attribute Details

#excludeObject (readonly)

Returns the value of attribute exclude.



10
11
12
# File 'lib/firespring_dev_commands/templates/base_interface.rb', line 10

def exclude
  @exclude
end

Instance Method Details

#create_tasks!Object

This method executes all instance methods which match “create_.*_task!” This way a user can easily add new methods to the default template simply by defining new create methods on the class which follow the naming convention



20
21
22
23
24
25
26
# File 'lib/firespring_dev_commands/templates/base_interface.rb', line 20

def create_tasks!
  self.class.instance_methods(false).sort.each do |method|
    next unless /create_.*_task!/.match?(method)

    send(method)
  end
end