Skip to content

Commit

Permalink
added inspect method to class
Browse files Browse the repository at this point in the history
  • Loading branch information
scalabl3 committed Feb 15, 2013
1 parent 7c78c82 commit e9a50f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/couchbase_settings.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def setup!
def find_ymls def find_ymls
main_file = "#{Rails.root.to_s}/config/couchbase.yml" main_file = "#{Rails.root.to_s}/config/couchbase.yml"
couchbase_main_file = File.exists?(main_file) ? [main_file] : [] couchbase_main_file = File.exists?(main_file) ? [main_file] : []
couchbase_main_file
end end


def create_cbsettings_class(yml_file) def create_cbsettings_class(yml_file)
Expand All @@ -27,6 +28,10 @@ def create_cbsettings_class(yml_file)
#Rails.logger.debug "hash: key = #{key}, value = #{value}" #Rails.logger.debug "hash: key = #{key}, value = #{value}"
klass.define_singleton_method(key){ value } klass.define_singleton_method(key){ value }
end end

# add a method to inspect the entire yml hash
klass.define_singleton_method("inspect", hash)

klass.class_eval do klass.class_eval do
def self.method_missing(method_id,*args) def self.method_missing(method_id,*args)
raise UndefinedCouchbaseSettings, "#{method_id} is not defined in #{self.to_s}" raise UndefinedCouchbaseSettings, "#{method_id} is not defined in #{self.to_s}"
Expand Down
2 changes: 1 addition & 1 deletion lib/couchbase_settings/version.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,3 @@
module CouchbaseSettings module CouchbaseSettings
VERSION = "0.1.1" VERSION = "0.1.2"
end end

0 comments on commit e9a50f1

Please sign in to comment.