module Her::Model
This module is the main element of Her
. After creating a Her::API
object, include this module in your models to get a few magic methods defined in them.
@example
class User include Her::Model end @user = User.new(:name => "Rémi") @user.save
Public Instance Methods
[](attribute_name)
click to toggle source
Returns
-
the value of the attribute_nane attribute if it’s in orm data
-
the resource/collection corrsponding to attribute_name if it’s a relationship
# File lib/her/model.rb, line 64 def [](attribute_name) get_data(attribute_name) || get_relationship(attribute_name) end
has_key?(attribute_name)
click to toggle source
Returns true if attribute_name is
-
in orm data
-
a relationship
# File lib/her/model.rb, line 56 def has_key?(attribute_name) has_data?(attribute_name) || has_relationship?(attribute_name) end