Sha256: 75ceb1a62c36d8887e3a9d4d00f2f50a528362c2fb9928d6577c579cbcdb0116

Contents?: true

Size: 822 Bytes

Versions: 7

Compression:

Stored size: 822 Bytes

Contents

module GeoConcerns
  module MetadataExtractionHelper
    # Extracts properties from the constitutent external metadata file
    # @return [Hash]
    def extract_metadata
      return {} if metadata_files.blank?
      # TODO: Does not support multiple external metadata files
      raise NotImplementedError if metadata_files.length > 1
      metadata_files.first.extract_metadata
    end

    # Sets properties from the constitutent external metadata file
    def populate_metadata
      extract_metadata.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?
      return unless should_populate_metadata
      populate_metadata
      save
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
geo_concerns-0.0.7 app/models/concerns/geo_concerns/metadata_extraction_helper.rb
geo_concerns-0.0.6 app/models/concerns/geo_concerns/metadata_extraction_helper.rb
geo_concerns-0.0.5 app/models/concerns/geo_concerns/metadata_extraction_helper.rb
geo_concerns-0.0.4 app/models/concerns/geo_concerns/metadata_extraction_helper.rb
geo_concerns-0.0.3 app/models/concerns/geo_concerns/metadata_extraction_helper.rb
geo_concerns-0.0.2 app/models/concerns/geo_concerns/metadata_extraction_helper.rb
geo_concerns-0.0.1 app/models/concerns/geo_concerns/metadata_extraction_helper.rb