lib/her/model/parse.rb
# Return or change the value of `root_element`. Always defaults to the base name of the class.
#
# @example
#   class User
#     include Her::Model
#     parse_root_in_json true
#     root_element :huh
#   end
#
#   user = User.find(1) # { :huh => { :id => 1, :name => "Tobias" } }
#   user.name # => "Tobias"
Return or change the value of `root_element`. Always defaults to the base name of the class.
Return or change the value of ` root_element ` . Always defaults to the base name of the class .
def root_element(value = nil)
          if value.nil?
            @_her_root_element ||= if json_api_format?
                                     name.split("::").last.pluralize.underscore.to_sym
                                   else
                                     name.split("::").last.underscore.to_sym
                                   end
          else
            @_her_root_element = value.to_sym
          end
        end
def root_element ( value = nil ) if value . nil? @_her_root_element ||= if json_api_format? name . split ( "::" ) . last . pluralize . underscore . to_sym else name . split ( "::" ) . last . underscore . to_sym end else @_her_root_element = value . to_sym end end
Return or change the value of `root_element`.
Return or change the value of ` root_element ` .
value
<not_specific>
example
class User include Her::Model parse_root_in_json true root_element :huh end user = User.find(1) # { :huh => { :id => 1, :name => "Tobias" } } user.name # => "Tobias"
class User include Her :: Model parse_root_in_json true root_element : huh end user = User . find ( 1 ) # { : huh = > { : id = > 1 : name = > " Tobias " } } user . name # = > " Tobias "