Class: Accessionable::Base::Tag
- Inherits:
-
Object
- Object
- Accessionable::Base::Tag
- Defined in:
- app/models/accessionable/base.rb
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.
161 162 163 164 165 |
# File 'app/models/accessionable/base.rb', line 161 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.
71 72 73 |
# File 'app/models/accessionable/base.rb', line 71 def value @value end |
Instance Method Details
#build(xml) ⇒ Object
182 183 184 185 |
# File 'app/models/accessionable/base.rb', line 182 def build(xml) xml.TAG label xml.VALUE value end |
#field_serializer_for(name) ⇒ Object
178 179 180 |
# File 'app/models/accessionable/base.rb', line 178 def field_serializer_for(name) SERIALIZERS.detect { |s| s.applies_to?(name) } end |
#label ⇒ Object
167 168 169 170 171 172 173 174 175 176 |
# File 'app/models/accessionable/base.rb', line 167 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 |