|
NAMEJifty::Record - Represents a Jifty object that lives in the database.DESCRIPTION"Jifty::Record" is a kind of Jifty::Object that has a database representation; that is, it is also a Jifty::DBI::Record as well.METHODScreate PARAMHASH"create" can be called as either a class method or an object method.Takes an array of key-value pairs and inserts a new row into the database representing this object. Overrides Jifty::DBI::Record in these ways:
idReturns the record id value. This routine short-circuits a much heavier call up through Jifty::DBIload_or_create"load_or_create" can be called as either a class method or an object method. It attempts to load a record with the named parameters passed in. If it can't do so, it creates a new record.as_create_action PARAMHASHReturns the Jifty::Action::Record::Create action for this model class.The PARAMHASH allows you to add additional parameters to pass to "new_action" in Jifty::Web. as_update_action PARAMHASHReturns the Jifty::Action::Record::Update action for this model class. The current record is passed to the constructor.The PARAMHASH allows you to add additional parameters to pass to "new_action" in Jifty::Web. as_delete_action PARAMHASHReturns the Jifty::Action::Record::Delete action for this model class. The current record is passed to the constructor.The PARAMHASH allows you to add additional parameters to pass to "new_action" in Jifty::Web. as_search_action PARAMHASHReturns the Jifty::Action::Record::Search action for this model class.The PARAMHASH allows you to add additional parameters to pass to "new_action" in Jifty::Web. _guess_table_nameGuesses a table name based on the class's last part. In addition to the work performed in Jifty::DBI::Record, this method also prefixes the table name with the plugin table prefix, if the model belongs to a plugin.current_user_can RIGHT [ATTRIBUTES]Should return true if the current user ("$self->current_user") is allowed to do RIGHT. Possible values for RIGHT are:
Models wishing to customize authorization checks should override this method. You can do so like this: sub current_user_can { my ($self, $right, %args) = @_; # Make any custom checks that return 1 to allow or return 0 to deny... # Fallback upon the default implementation to handle the # SkipAccessControl configuration setting, superuser, bootstrap, # delegation, and the before_access hook return $self->SUPER::current_user_can($right, %args); } If you are sure you don't want your model to fallback using the default implementation, you can replace the last line with whatever fallback policy required. Authorization steps The default implementation proceeds as follows:
The before_access hook This implementation may make use of a trigger called "before_access" to make the decision. A new handler can be added to the trigger point by calling "add_handler": $record->add_trigger( name => 'before_access', code => \&before_access, abortable => 1, ); The "before_access" handler will be passed the same arguments that were used to call "current_user_can", including the current record object, the operation being checked, and any arguments being passed to the operation. The "before_access" handler should return one of three strings: 'deny', 'allow', or 'ignore'. The "current_user_can" implementation reacts as follows to these results:
check_create_rights ATTRIBUTESInternal helper to call "current_user_can" with "create".check_read_rightsInternal helper to call "current_user_can" with "read".Passes "column" as a named parameter for the column the user is checking rights on. check_update_rightsInternal helper to call "current_user_can" with "update".check_delete_rightsInternal helper to call "current_user_can" with "delete".as_user CurrentUserReturns a copy of this object with the current_user set to the given current_user. This is a way to act on behalf of a particular user (perhaps the owner of the object)as_superuserReturns a copy of this object with the current_user set to the superuser. This is a convenient way to duck around ACLs if you have code that needs to for some reason or another.delete PARAMHASHOverrides Jifty::DBI::Record to check the delete ACL.brief_descriptionDisplay the friendly name of the record according to _brief_description.To change what this returns, override _brief_description instead. _brief_descriptionWhen displaying a list of records, Jifty can display a friendly value rather than the column's unique id. Out of the box, Jifty always tries to display the 'name' field from the record. If there is no 'name' field, Jifty falls back to the record id.You can override this method to return the name of a method on your record class which will return a nice short human readable description for this record. null_referenceBy default, Jifty::DBI::Record returns "undef" on non-existent related fields; Jifty prefers to get back an object with an undef id._new_collection_argsOverrides the default arguments which this collection passes to new collections, to pass the "current_user"._new_record_argsOverrides the default arguments which this collection passes to new records, to pass the "current_user".cache_key_prefixReturns a unique key for this application for the Memcached cache. This should be global within a given Jifty application instance.sinceBy default, all models exist since "undef", the ur-time when the application was created. Please override it for your model class.printable_table_schemaWhen called, this method will generate the SQL schema for the current version of this class and return it as a scalar, suitable for printing or execution in your database's command line.table_schema_statementsWhen called, this method will generate the SQL schema statements for the current version of this class and return it as array.create_table_in_dbWhen called, this method will generate the SQL schema for the current version of this class and insert it into the application's currently open database.drop_table_in_dbWhen called, this method will generate the SQL to remove this model's table in the database and execute it in the application's currently open database. This method can destroy a lot of data. Be sure you know what you're doing.add_column_sql column_nameReturns the SQL statement necessary to add "column_name" to this class's representation in the databaseadd_column_in_db column_nameExecutes the SQL code generated by add_column_sql. Dies on failure.drop_column_sql column_nameReturns the SQL statement necessary to remove "column_name" from this class's representation in the databasedrop_column_in_db column_nameExecutes the SQL code generated by drop_column_sql. Dies on failure.schema_versionThis method is used by Jifty::DBI::Record to determine which schema version is in use. It returns the current database version stored in the configuration.Jifty's notion of the schema version is currently broken into two:
A model is considered to be defined by Jifty if it the package name starts with "Jifty::". Otherwise, it is assumed to be an application model. column_serialized_asdefault_serialized_as_columnsjifty_serialize_formatThis is used to create a hash reference of the object's values. Unlike Jifty::DBI::Record->as_hash, this won't transform refers_to columns into JDBI objects. Override this if you want to include calculated values (for use in, say, your REST interface)autogenerate_actionControls which of the Jifty::Action::Record subclasses are automatically set up for this model; this subroutine is passed one of the strings "Create", "Update", "Delete", "Search" or "Execute", and should return a true value if that action should be autogenerated.The default method returns 0 for all action classes if the model is marked as "is_private". It returns 0 for all actions that are not "Search" if the model is marked as "is_protected"; otherwise, it returns true. is_privateOverride this method to return true to not generate any actions for this model, and to hide it from REST introspection.is_protectedOverride this method to return true to only generate Search actions for this model.enumerableControls whether autogenerated actions with columns that refer to this class should attempt to provide a drop-down of possible values or not. This method will be called as a class method, and defaults to true.
Visit the GSP FreeBSD Man Page Interface. |