Sha256: 5b2f79adf9c9ee2e51709867a907c255703769c5cde0a1a4176e77099c35b8a1

Contents?: true

Size: 514 Bytes

Versions: 1

Compression:

Stored size: 514 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)
      collection_klass.records.detect{|obj| obj.name == name } if name.present?
    end

    def find_by_slug(slug)
      collection_klass.records.detect{|obj| obj.slug == slug } if slug.present?
    end

    def find(id)
      collection_klass.records.detect{|obj| obj.id == id } if id.present?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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