Class: Accessionable::Base::Tag
- Inherits:
-
Object
- Object
- Accessionable::Base::Tag
- Defined in:
- app/models/accessionable/base.rb
Direct Known Subclasses
Defined Under Namespace
Classes: FieldCollectionDate, FieldCountryOfOrigin, FieldSerializer
Constant Summary collapse
- SERIALIZERS =
[FieldCountryOfOrigin.new, FieldCollectionDate.new, FieldSerializer.new].freeze
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #build(xml) ⇒ Object
- #field_serializer_for(name) ⇒ Object
-
#initialize(label_scope, name, value, downcase = false) ⇒ Tag
constructor
A new instance of Tag.
- #label ⇒ Object
Constructor Details
#initialize(label_scope, name, value, downcase = false) ⇒ Tag
Returns a new instance of Tag.
171 172 173 174 175 |
# File 'app/models/accessionable/base.rb', line 171 def initialize(label_scope, name, value, downcase = false) @name = name @value = field_serializer_for(name).value_for(downcase && value ? value.downcase : value) @scope = label_scope end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
81 82 83 |
# File 'app/models/accessionable/base.rb', line 81 def value @value end |
Instance Method Details
#build(xml) ⇒ Object
192 193 194 195 |
# File 'app/models/accessionable/base.rb', line 192 def build(xml) xml.TAG label xml.VALUE value end |
#field_serializer_for(name) ⇒ Object
188 189 190 |
# File 'app/models/accessionable/base.rb', line 188 def field_serializer_for(name) SERIALIZERS.detect { |s| s.applies_to?(name) } end |
#label ⇒ Object
177 178 179 180 181 182 183 184 185 186 |
# File 'app/models/accessionable/base.rb', line 177 def label accessioning_tag = I18n.exists?("#{@scope}.#{@name}.accessioning_tag") # check for field override for when ebi name is different from sanger name # NB. replace any underscores with spaces and ensure in lowercase return I18n.t("#{@scope}.#{@name}.accessioning_tag").tr('_', ' ').downcase if accessioning_tag # For the rest the ebi name is the same as the sanger name I18n.t("#{@scope}.#{@name}.label").tr('_', ' ').downcase end |