Sha256: f3ff617c7918a22bb1b48ce578e7a2cef6462e77b50ac6e0432a5df94453967d

Contents?: true

Size: 698 Bytes

Versions: 9

Compression:

Stored size: 698 Bytes

Contents

# encoding: utf-8
module Sunrise
  module Utils
    module AccessibleAttributes
      def self.included(base)
        base.send(:extend, ClassMethods)
        base.send(:include, InstanceMethods)
      end
      
      module ClassMethods
        def self.extended(base)  
          base.class_eval do
            attr_accessible
            attr_accessor :accessible
          end
        end
      end
      
      module InstanceMethods
        private
    
          def mass_assignment_authorizer
            if accessible == :all
              self.class.protected_attributes
            else
              super + (accessible || [])
            end
          end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sunrise-core-0.2.2 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.2.1 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.2.0 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.1.5 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.1.4 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.1.3 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.1.2 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.1.1 lib/sunrise/utils/accessible_attributes.rb
sunrise-core-0.1.0 lib/sunrise/utils/accessible_attributes.rb