Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use ActiveSupport::Concern over old method

  • Loading branch information...
commit 171eec9e3e97b6337f96928c8e5e62815b198de6 1 parent 68be571
Chris Harper authored
Showing with 10 additions and 14 deletions.
  1. +9 −13 lib/only_expose.rb
  2. +1 −1  lib/only_expose/version.rb
View
22 lib/only_expose.rb
@@ -1,25 +1,21 @@
+require 'active_support/concern'
module OnlyExpose
+ extend ActiveSupport::Concern
- def self.included(base)
- base.extend ClassMethods
- end
-
- #Instance Methods
-
- def to_json(options = {})
- super(options.merge(:only => self.class.exposed_attributes))
- end
+ included do
+ def to_json(options = {})
+ super(options.merge(:only => self.class.exposed_attributes))
+ end
- def to_xml(options = {})
- super(options.merge(:only => self.class.exposed_attributes))
+ def to_xml(options = {})
+ super(options.merge(:only => self.class.exposed_attributes))
+ end
end
module ClassMethods
-
def only_expose(*args)
@exposed_attributes = *args
end
-
def exposed_attributes
if @exposed_attributes.nil? && self.superclass != ActiveRecord::Base
superclass.exposed_attributes
View
2  lib/only_expose/version.rb
@@ -1,3 +1,3 @@
module OnlyExpose
- VERSION = '0.1.0'
+ VERSION = '0.2.0'
end
Please sign in to comment.
Something went wrong with that request. Please try again.