lib/trust/controller/properties.rb in trust-0.6.3 vs lib/trust/controller/properties.rb in trust-0.7.0

- old
+ new

@@ -22,20 +22,21 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. module Trust module Controller + # = Trust Coontroller Properties class Properties delegate :logger, :to => Rails attr_reader :controller attr_accessor :model attr_accessor :associations attr_accessor :new_actions attr_accessor :member_actions attr_accessor :collection_actions - def initialize(controller, properties) # nodoc + def initialize(controller, properties) #:nodoc: @controller = controller @model = controller.controller_path if properties @associations = properties.associations.dup @new_actions = properties.new_actions.dup @@ -48,20 +49,22 @@ @collection_actions = [:index] end end class << self - # returns a controller properties object - # ensures controller properties are instantiated in a correct manner and that inheritance is supported + # Returns a controller properties object. + # + # Ensures controller properties are instantiated in a correct manner and that inheritance is supported def instantiate(controller) new(controller, controller.superclass.instance_variable_get(:@properties)) end end - # returns or sets the model to be used in a controller - # If not set, the controller_path is used - # You can override the model to be accessed in a controller by setting the model + # Returns or sets the model to be used in a controller + # + # If not set, the controller_path is used. + # You can override the model to be accessed in a controller by setting the model. # Note that you should specify the model in plural form. # # ==== Example # # # You have a controller which inherits from a generic controller and it has not the same name. Below @@ -79,15 +82,17 @@ def model_class model.to_s.classify.constantize end # Specify associated resources (nested resources) - # Example: - # belongs_to :lottery - # belongs_to :table, :card_game - # belongs_to :card_game, :as => :bridge # + # === Example + # + # +belongs_to+ :lottery + # +belongs_to+ :table, :card_game + # +belongs_to+ :card_game, :as => :bridge + # def belongs_to(*resources) raise ArgumentError, "You must specify at least one resource after belongs_to" unless resources logger.debug "#{@model} belongs_to #{resources.inspect}" options = resources.extract_options! resources.each do |resource| @@ -97,11 +102,13 @@ def has_associations? @associations.size > 0 end - # actions(options) - # Options + # Specify actions to handle + # + # === Options + # # :new => actions # specify new actions - default id :new, :create # :member => actions # specify member actions - default is :show, :edit, :update, :destroy # :collection => actions # specify collection actions - default is :index # :except => actions # removes any standard actions # :only => actions # selects only the standard actions specifiec