Sha256: f132f7fbbc11a7e58959840bbd88d82014d2dbad9f990c711443cd4eb6748e23

Contents?: true

Size: 625 Bytes

Versions: 5

Compression:

Stored size: 625 Bytes

Contents

# encoding: utf-8
module Freeberry
  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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
freeberry-0.3.0 lib/freeberry/accessible_attributes.rb
freeberry-0.2.9 lib/freeberry/accessible_attributes.rb
freeberry-0.2.7 lib/freeberry/accessible_attributes.rb
freeberry-0.2.6 lib/freeberry/accessible_attributes.rb
freeberry-0.2.5 lib/freeberry/accessible_attributes.rb