Sha256: 636440404397d9b4f71f869667a40c27c78d11caa021da5bdc58cfa6564d12f1

Contents?: true

Size: 589 Bytes

Versions: 1

Compression:

Stored size: 589 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 == id }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ine-places-0.1.1 lib/ine/places/csv_record.rb