Sha256: db33418236ccef4935d642fbe8b48315f8ee19c33c12e18b5848e933695685ca
Contents?: true
Size: 1.7 KB
Versions: 7
Compression:
Stored size: 1.7 KB
Contents
require 'active_support/concern' require 'iord/defaults' require 'iord/resource_info' require 'iord/resource_url' require 'iord/crud' require 'iord/attributes' require 'iord/fields' require 'iord/resolver' # Not included, but made available require 'iord/paginate' require 'iord/sort' require 'iord/search' require 'iord/iterable' # Information Oriented Representation of Data module Iord module Controller extend ActiveSupport::Concern include Iord::Defaults include Iord::ResourceInfo include Iord::ResourceUrl include Iord::Attriutes include Iord::Crud include Iord::Fields included do append_view_path Iord::Resolver.new before_action :set_resource cattr_accessor :resource_based_actions, instance_accesssor: false do %i(show edit update destroy) end cattr_accessor :iord_features do Array.new end helper_method :iord_features end module ClassMethods def resource_actions(*actions) actions = *actions if actions.size == 1 and actions[0].is_a? Array self.resource_based_actions = self.resource_based_actions + actions end alias_method :resource_action, :resource_actions def resource_actions!(*actions) actions = *actions if actions.size == 1 and actions[0].is_a? Array self.resource_based_actions = actions end end protected def set_resource return unless self.class.resource_based_actions.include? params[:action].to_sym if params[:id] @resource = resource_class.find params[:id] elsif resource_class.count > 0 @resource = resource_class.first else @resource = resource_class.new end end end end
Version data entries
7 entries across 7 versions & 1 rubygems