Module: Her::Model::Introspection

Extended by:
ActiveSupport::Concern
Included in:
Her::Model
Defined in:
lib/her/model/introspection.rb

Instance Method Summary collapse

Instance Method Details

#inspectObject

Inspect an element, returns it for introspection.

Examples:

class User
  include Her::Model
end

@user = User.find(1)
p @user # => #<User(/users/1) id=1 name="Tobias Fünke">


14
15
16
17
18
19
20
21
22
# File 'lib/her/model/introspection.rb', line 14

def inspect
  resource_path = begin
    request_path
  rescue Her::Errors::PathError => e
    "<unknown path, missing `#{e.missing_parameter}`>"
  end

  "#<#{self.class}(#{resource_path}) #{attributes.keys.map { |k| "#{k}=#{attribute_for_inspect(send(k))}" }.join(" ")}>"
end