Sha256: 31d9e08269ee7a3ae993e9909a2e877b9124be2cf81f7e0bd138acad6f5ed74f

Contents?: true

Size: 552 Bytes

Versions: 23

Compression:

Stored size: 552 Bytes

Contents

# encoding: utf-8

module HalApi::RepresentedModel
  extend ActiveSupport::Concern

  # this concept is used in result set, perhaps doesn't belong in model itself
  # consider if there is a better way to do this - decorate model instead?
  attr_accessor :is_root_resource

  def is_root_resource
    !!@is_root_resource
  end

  def show_curies
    is_root_resource
  end

  def id_from_url(url)
    Rails.application.routes.recognize_path(url)[:id]
  end

  included do
    extend ActiveModel::Naming unless (method(:model_name) rescue nil)
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
hal_api-rails-1.2.2 lib/hal_api/represented_model.rb
hal_api-rails-1.2.1 lib/hal_api/represented_model.rb
hal_api-rails-1.2.0 lib/hal_api/represented_model.rb
hal_api-rails-1.1.5 lib/hal_api/represented_model.rb
hal_api-rails-1.1.4 lib/hal_api/represented_model.rb
hal_api-rails-0.3.7 lib/hal_api/represented_model.rb
hal_api-rails-0.3.6 lib/hal_api/represented_model.rb
hal_api-rails-1.1.3 lib/hal_api/represented_model.rb
hal_api-rails-0.3.5 lib/hal_api/represented_model.rb
hal_api-rails-1.1.2 lib/hal_api/represented_model.rb
hal_api-rails-1.1.1 lib/hal_api/represented_model.rb
hal_api-rails-1.1.0 lib/hal_api/represented_model.rb
hal_api-rails-1.0.0 lib/hal_api/represented_model.rb
hal_api-rails-0.7.0 lib/hal_api/represented_model.rb
hal_api-rails-0.6.0 lib/hal_api/represented_model.rb
hal_api-rails-0.5.0 lib/hal_api/represented_model.rb
hal_api-rails-0.4.1 lib/hal_api/represented_model.rb
hal_api-rails-0.4.0 lib/hal_api/represented_model.rb
hal_api-rails-0.3.4 lib/hal_api/represented_model.rb
hal_api-rails-0.3.3 lib/hal_api/represented_model.rb