Sha256: df16988e1c1d9553c6b1a06833452a95ca8698db54ca75e21f315b72b1433ddc

Contents?: true

Size: 1.3 KB

Versions: 215

Compression:

Stored size: 1.3 KB

Contents

class EntityActionController
  attr_accessor :entity, :id
  attr_accessor :actions

  def initialize(entity, id = nil)
    @entity, @id = entity, id
    @actions = []
  end

  def add(action, text = nil, resource = nil, params = {})
    text = action if text.nil?
    resource = action.respond_to?(:resource) ? action.resource : nil
    resource ||= "Rbbt"
    @actions << [action, text, resource, params]
  end

end

module EntityRESTHelpers
  def default_action_controller(entity, list_id = nil)
    action_controller = EntityActionController.new(entity, list_id)

    case
    when Array === entity
      find_all_entity_list_action_templates(entity, true).each do |action|
        action_controller.add action, Misc.humanize(action, :format => :sentence), :reuse => true
      end
    when TSV === entity
      find_all_entity_map_action_templates(entity, true).each do |action|
        action_controller.add action, Misc.humanize(action, :format => :sentence), :reuse => true
      end
    else
      find_all_entity_action_templates(entity, true).each do |action|
        action_controller.add action, Misc.humanize(action, :format => :sentence)
      end
    end
    action_controller
  end

  def action_controller_render(controller)
    partial_render('entity_partials/action_controller', :controller => controller)
  end
end

Version data entries

215 entries across 215 versions & 1 rubygems

Version Path
rbbt-rest-2.0.1 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-2.0.0 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.9.1 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.9.0 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.157 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.156 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.155 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.154 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.152 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.151 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.150 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.148 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.147 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.146 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.145 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.144 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.143 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.142 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.140 lib/rbbt/rest/entity/action_controller.rb
rbbt-rest-1.8.139 lib/rbbt/rest/entity/action_controller.rb