Sha256: 27f195178412d2c1117840a3f481b24db3e55308a1aecb818e331755ef725f7b

Contents?: true

Size: 828 Bytes

Versions: 56

Compression:

Stored size: 828 Bytes

Contents

class RailsOps::Operation::Model::Create < RailsOps::Operation::Model
  model_authorization_action :create

  policy :on_init do
    model_authorization
  end

  # As this operation might extend the model class, we need to make sure that
  # the operation works using an extended 'copy' of the given model class.
  def self.always_extend_model_class?
    true
  end

  def model_authorization
    return unless authorization_enabled?

    unless model_authorization_action.nil?
      authorize_model! model_authorization_action, model
    end
  end

  def build_model
    fail 'Model can only be built once.' if @model
    @model = self.class.model.new
    if @model.respond_to?(:parent_op=)
      @model.parent_op = self
    end
    build_nested_model_ops :create
    assign_attributes
  end

  def perform
    save!
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
rails_ops-1.0.21 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.20 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.19 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.18 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.17 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.16 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.15 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.14 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.13 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.12 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.11 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.10 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.9 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.7 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.6 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.5 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.4 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.3 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.2 lib/rails_ops/operation/model/create.rb
rails_ops-1.0.1 lib/rails_ops/operation/model/create.rb