Class: AddMetric

Inherits:
Struct
  • Object
show all
Defined in:
lib/commands/add_metric.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



1
2
3
# File 'lib/commands/add_metric.rb', line 1

def name
  @name
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



1
2
3
# File 'lib/commands/add_metric.rb', line 1

def project_name
  @project_name
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



1
2
3
# File 'lib/commands/add_metric.rb', line 1

def type
  @type
end

Instance Method Details

#call(project = project, metric = metric) ⇒ Object



2
3
4
# File 'lib/commands/add_metric.rb', line 2

def call project = project, metric = metric
  project.add_metric(metric)
end

#metric(metric_class = metric_class, name = name) ⇒ Object



10
11
12
# File 'lib/commands/add_metric.rb', line 10

def metric metric_class = metric_class, name = name
  metric_class.new name: name
end

#metric_class(type = type) ⇒ Object



14
15
16
# File 'lib/commands/add_metric.rb', line 14

def metric_class type = type
  "#{type}Metric".classify.constantize
end

#project(project_name = project_name) ⇒ Object



6
7
8
# File 'lib/commands/add_metric.rb', line 6

def project project_name = project_name
  Project.find_by(name: project_name)
end