Files
nairobi/app/components/admin/budgets/duration_in_words_component.rb
Javi Martín 7227815a16 Split duration component in two
We were displaying dates in two different formats in the same component,
leading to strange hacks like manually calling the `call` method or not
being able to use `render_inline` in the tests.

Since we're going to reuse one of these formats outside the budgets
section, we're splitting the component. We're also removing the
mentioned hacks.
2022-09-14 15:14:23 +02:00

18 lines
320 B
Ruby

class Admin::Budgets::DurationInWordsComponent < ApplicationComponent
attr_reader :durable
def initialize(durable)
@durable = durable
end
def render?
durable.starts_at && durable.ends_at
end
private
def duration
distance_of_time_in_words(durable.starts_at, durable.ends_at)
end
end