Sha256: 8f530202c14826005d433b00d59ccd97e6da8e9ad9e1ce6c578089e630485593

Contents?: true

Size: 599 Bytes

Versions: 4

Compression:

Stored size: 599 Bytes

Contents

module INE::Places::CSVRecord
  extend ::ActiveSupport::Concern

  def to_param
    self.slug
  end

  class_methods do

    def all
      collection_klass.records
    end

    def find_by_name(name)
      raise ArgumentError if name.blank?

      collection_klass.records.detect{|obj| obj.name == name }
    end

    def find_by_slug(slug)
      raise ArgumentError if slug.blank?

      collection_klass.records.detect{|obj| obj.slug == slug }
    end

    def find(id)
      raise ArgumentError if id.blank?

      collection_klass.records.detect{|obj| obj.id.to_i == id.to_i }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ine-places-0.1.5 lib/ine/places/csv_record.rb
ine-places-0.1.4 lib/ine/places/csv_record.rb
ine-places-0.1.3 lib/ine/places/csv_record.rb
ine-places-0.1.2 lib/ine/places/csv_record.rb