Skip to content

Commit

Permalink
Add super to inherited and included hook
Browse files Browse the repository at this point in the history
Thank you, RuboCop!
  • Loading branch information
okuramasafumi committed Aug 8, 2020
1 parent 9922df2 commit 8d38d59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/alba/resource.rb
Expand Up @@ -8,6 +8,7 @@ module Alba
module Resource
DSLS = [:_attributes, :_serializer, :_key].freeze
def self.included(base)
super
base.class_eval do
# Initialize
DSLS.each do |name|
Expand Down Expand Up @@ -91,6 +92,7 @@ module ClassMethods
attr_reader(*DSLS)

def inherited(subclass)
super
DSLS.each { |name| subclass.instance_variable_set("@#{name}", instance_variable_get("@#{name}")) }
end

Expand Down
2 changes: 2 additions & 0 deletions lib/alba/serializer.rb
Expand Up @@ -2,6 +2,7 @@ module Alba
# This module represents how a resource should be serialized.
module Serializer
def self.included(base)
super
base.include InstanceMethods
base.extend ClassMethods
end
Expand Down Expand Up @@ -43,6 +44,7 @@ module ClassMethods
attr_reader :_opts, :_metadata

def inherited(subclass)
super
%w[_opts _metadata].each { |name| subclass.instance_variable_set("@#{name}", instance_variable_get("@#{name}")) }
end

Expand Down

0 comments on commit 8d38d59

Please sign in to comment.