Module: Auxilium::Concerns::Metadata
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/auxilium/concerns/metadata.rb
Instance Method Summary collapse
Instance Method Details
#metadata ⇒ Object
32 33 34 |
# File 'lib/auxilium/concerns/metadata.rb', line 32 def attributes['metadata'].present? && HashWithIndifferentAccess.new(attributes['metadata']) end |
#metadata_yaml ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/auxilium/concerns/metadata.rb', line 18 def return '' if attributes['metadata'].blank? if attributes['metadata'].is_a? String begin YAML.load(attributes['metadata']) rescue StandardError attributes['metadata'] end else YAML.dump(attributes['metadata']) end end |
#metadata_yaml=(yaml) ⇒ Object
12 13 14 15 16 |
# File 'lib/auxilium/concerns/metadata.rb', line 12 def (yaml) write_attribute :metadata, YAML.safe_load(yaml.gsub("\t", ' ')) rescue StandardError write_attribute :metadata, yaml end |