Sha256: 9664dbaddc643adb409487c7e6d6970e7beb3bb1558fbb84ac1ca314394ddf38

Contents?: true

Size: 575 Bytes

Versions: 5

Compression:

Stored size: 575 Bytes

Contents

# Assigns an additional instance variable for +@model+ named after the model's table name (e.g. @comment).
module Trailblazer::Operation::Controller::ActiveRecord
private
  def setup_operation_instance_variables!(operation, options)
    super
    instance_variable_set(:"@#{operation_model_name}", @model)
  end

  def operation_model_name
    # set the right variable name if collection
    if @operation.is_a?(Trailblazer::Operation::Collection)
      return @model.model.table_name.split(".").last
    end
    @model.class.table_name.split(".").last.singularize
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
trailblazer-rails-0.1.5 lib/trailblazer/operation/controller/active_record.rb
trailblazer-rails-0.1.4 lib/trailblazer/operation/controller/active_record.rb
trailblazer-rails-0.1.3 lib/trailblazer/operation/controller/active_record.rb
trailblazer-rails-0.1.2 lib/trailblazer/operation/controller/active_record.rb
trailblazer-1.0.0.rc2 lib/trailblazer/operation/controller/active_record.rb