Sha256: 9384fabbc46b8933abf3cc73f8f8581ea946d079edf70bf9a7f7a3b7f8553537

Contents?: true

Size: 714 Bytes

Versions: 30

Compression:

Stored size: 714 Bytes

Contents

class Ey::Core::Model < Cistern::Model
  def url
    if self.class.attributes[:url]
      read_attribute(:url)
    else
      "#{self.collection.url}/#{self.id}"
    end
  end

  def to_s
    shortname = self.class.name.split("::").last
    "#{shortname}:#{id}"
  end

  def self.range_parser(v)
    case v
    when Range then
      v
    when String then
      first, last = v.split("-").map(&:to_i)
      last ||= first
      Range.new(first, last)
    else
      v
    end
  end

  def update!(attributes)
    merge_attributes(attributes)
    save!
  end

  def save
    save!
  rescue Ey::Core::Response::Error
    false
  end

  def destroy
    destroy!
  rescue Ey::Core::Response::Error
    false
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
ey-core-3.6.0.autoscaling1 lib/ey-core/model.rb
ey-core-3.6.4 lib/ey-core/model.rb
ey-core-3.6.3 lib/ey-core/model.rb
ey-core-3.6.1 lib/ey-core/model.rb
groove-ey-core-3.6.3 lib/ey-core/model.rb
groove-ey-core-3.6.2 lib/ey-core/model.rb
groove-ey-core-3.6.1 lib/ey-core/model.rb
ey-core-3.5.0 lib/ey-core/model.rb
ey-core-3.4.4 lib/ey-core/model.rb
ey-core-3.4.2 lib/ey-core/model.rb
ey-core-3.4.1 lib/ey-core/model.rb
ey-core-3.4.0 lib/ey-core/model.rb
ey-core-3.3.1 lib/ey-core/model.rb
ey-core-3.3.0 lib/ey-core/model.rb
ey-core-3.2.6 lib/ey-core/model.rb
ey-core-3.2.5 lib/ey-core/model.rb
ey-core-3.2.4 lib/ey-core/model.rb
ey-core-3.2.3 lib/ey-core/model.rb
ey-core-3.2.2 lib/ey-core/model.rb
ey-core-3.2.1 lib/ey-core/model.rb