Oshuma / app_config

Simple Ruby framework-agnostic application configuration.
http://oshuma.github.io/app_config/
MIT License
20 stars 7 forks source link

No access by symbols #12

Closed DSIW closed 12 years ago

DSIW commented 12 years ago

Input:

require "app_config"

config = AppConfig.setup do |config|
  config[:first] = 1
  config[:name] = "NAME"
end

p config[:first], config[:name]
p config["first"], config["name"]
p config.first, config.name

Ouput:

nil
nil
1
"NAME"
./config.rb:13:in `<main>': undefined method `name' for {"first"=>1, "name"=>"NAME"}:Hash (NoMethodError)

I'd like to access values by symbols and strings. You implemented this in your class Hashish, right? I tested it and it was correct, but if I use your class AppConfig I don't have access by symbols.

What is my problem? Thank's for help.

DSIW commented 12 years ago

I see my mistake in app_config/storage/yaml_spec.rb. I have to write it like this:

AppConfig[:first] = 1
AppConfig[:name] = "NAME"

I see also, that the return value of setup() is an Hash, then I can't access by symbols. But I think many people will use it like my first example. Could you change to return value of setup? People who want to use a Hash can use your to_hash method. Please give me feedback. Thank's.

Oshuma commented 12 years ago

This has been fixed in 1.0.2. AppConfig.setup now returns an instance of Hashish.

DSIW commented 12 years ago

Thank's for your quick reply.