Class: Sipity::Decorators::Recommendations::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Translation
Defined in:
app/decorators/sipity/decorators/recommendations/base.rb

Overview

The basis for any recommendation

Direct Known Subclasses

CitationRecommendation, DoiRecommendation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sip:, repository: nil, helper: nil) ⇒ Base

Returns a new instance of Base


11
12
13
14
15
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 11

def initialize(sip:, repository: nil, helper: nil)
  self.sip = sip
  @repository = repository || default_repository
  @helper = helper || default_helper
end

Instance Attribute Details

#helperObject (readonly, private)

Returns the value of attribute helper


8
9
10
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 8

def helper
  @helper
end

#repositoryObject (readonly, private)

Returns the value of attribute repository


8
9
10
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 8

def repository
  @repository
end

#sipObject

Returns the value of attribute sip


8
9
10
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 8

def sip
  @sip
end

Instance Method Details

#default_helperObject (private)


51
52
53
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 51

def default_helper
  sip.h
end

#default_repositoryObject (private)


47
48
49
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 47

def default_repository
  Repository.new
end

#human_attribute_name(name) ⇒ Object


33
34
35
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 33

def human_attribute_name(name)
  self.class.human_attribute_name(name)
end

#human_nameObject


29
30
31
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 29

def human_name
  I18n.translate("name", scope: translation_scope, title: sip.title)
end

#human_statusObject


25
26
27
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 25

def human_status
  I18n.translate("state.#{state}", scope: translation_scope, title: sip.title)
end

#path_to_recommendationObject


17
18
19
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 17

def path_to_recommendation
  fail NotImplementedError, "Expected #{self.class} to implement #path_to_recommendation"
end

#stateObject


21
22
23
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 21

def state
  fail NotImplementedError, "Expected #{self.class} to implement #state"
end

#translation_scopeObject (private)


55
56
57
# File 'app/decorators/sipity/decorators/recommendations/base.rb', line 55

def translation_scope
  self.class.model_name.i18n_key
end