Sha256: 8d0b6b994a1f56889935516aa56717be4721ac3c06c1d0365dc10aaf38849fa7

Contents?: true

Size: 797 Bytes

Versions: 6

Compression:

Stored size: 797 Bytes

Contents

module GeoWorks
  module MetadataExtractionHelper
    # Extracts properties from the constitutent external metadata file
    # @return [Hash]
    def extract_metadata(id)
      return {} if metadata_files.blank?
      metadata_file = metadata_files.find { |f| f.id == id }
      metadata_file.extract_metadata if metadata_file
    end

    # Sets properties from the constitutent external metadata file
    def populate_metadata(id)
      extract_metadata(id).each do |k, v|
        send("#{k}=".to_sym, v) # set each property
      end
    end

    attr_accessor :should_populate_metadata

    def should_populate_metadata=(args)
      @should_populate_metadata = args.present? && args != ''
      return unless should_populate_metadata
      populate_metadata(args)
      save
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geo_works-0.2.0 app/models/concerns/geo_works/metadata_extraction_helper.rb
geo_works-0.1.4 app/models/concerns/geo_works/metadata_extraction_helper.rb
geo_works-0.1.3 app/models/concerns/geo_works/metadata_extraction_helper.rb
geo_works-0.1.2 app/models/concerns/geo_works/metadata_extraction_helper.rb
geo_works-0.1.1 app/models/concerns/geo_works/metadata_extraction_helper.rb
geo_works-0.1.0 app/models/concerns/geo_works/metadata_extraction_helper.rb