Skip to content

Commit

Permalink
Split up methods so extensions can ask themselves these questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal Shah committed Aug 5, 2009
1 parent 63e7f5d commit a34ce66
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/radiant/extension.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def active?
@active @active
end end


def migrated?
migrator.new(:up, migrations_path).pending_migrations.empty?
end

def enabled?
active? and migrated?
end

def migrations_path def migrations_path
File.join(self.root, 'db', 'migrate') File.join(self.root, 'db', 'migrate')
end end
Expand All @@ -39,7 +47,7 @@ def admin
def extension_enabled?(extension) def extension_enabled?(extension)
begin begin
extension = (extension.to_s.camelcase + 'Extension').constantize extension = (extension.to_s.camelcase + 'Extension').constantize
extension.active? and extension.migrator.new(:up, extension.migrations_path).pending_migrations.empty? extension.enabled?
rescue NameError rescue NameError
false false
end end
Expand Down

0 comments on commit a34ce66

Please sign in to comment.