Sha256: fdc9b41358536fc1a67b01c51ec32d088aa745655004d0c8dca41ec2512b67df

Contents?: true

Size: 578 Bytes

Versions: 9

Compression:

Stored size: 578 Bytes

Contents

module Callbacks
  module Restrictor
    extend ActiveSupport::Concern

    included do
      mattr_accessor :initiator
      self.initiator = true

      attr_accessor :m

      define_method callback do |model|
        return unless initiator
        begin
          self.initiator = false
          self.m = model
          try :init
          __send__ "call"
        ensure
          self.initiator = true
        end
      end
    end

    class_methods do
      def callback
        "#{name.demodulize.underscore.split('_').last(2).join('_')}"
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_admin_cms-0.1.1 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.9 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.7 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.6 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.5 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.4 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.3 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.2 app/models/callbacks/restrictor.rb
rails_admin_cms-0.0.1 app/models/callbacks/restrictor.rb