I have an engine whom, in the lib/
directory has a configuration file as such:
# Default configration for groups, roles and permissions
class Xaaron::Configuration
# What is the memeber group name?
attr_accessor :member_group
# What is the memeber role name?
attr_accessor :member_role
# What is the admin group name?
attr_accessor :admin_group
# What is the admin role name?
attr_accessor :admin_role
# What is the can read permission name?
attr_accessor :can_read
# What is the can create permission name?
attr_accessor :can_create
# What is the can edit permission name?
attr_accessor :can_edit
# What is the can delete permission name?
attr_accessor :can_destroy
# Should we push this data to black bird? False by default.
attr_accessor :push_to_black_bird
# Defaults are set here.
def initialize
@member_group = 'Member'
@admin_group = 'Administrator'
@member_role = 'Member'
@admin_role = 'Administrator'
@can_read = 'can_read'
@can_create = 'can_create'
@can_edit = 'can_edit'
@can_destroy = 'can_destroy'
@push_to_black_bird = false
end
end
As you can see I have set the default values, incase you don't decide to change these. Now in this engines seed.rb
file I am able to do something like:
admin_group = Xaaron::Group.create(:group_name => Xaaron.config.admin_group, :can_alter => false, :can_delete => false)
And it works as intended, we see that Administrator
is set as the group name.
Now I tried to create the following, in the app that this engine is mounted in:
Xaaron.configure do |config|
config.push_to_black_bird = true
end
But when I booted the app, I got:
`block in <top (required)>': undefined method `push_to_black_bird=' for #<Xaaron::Configuration:0x007fbc6b305988> (NoMethodError)
Do I really have to define set and get methods for each of theses? I have seen other configuration files done in similar fashion.