Module: Rollable::Base::ClassMethods

Defined in:
lib/rollable/base.rb

Instance Method Summary collapse

Instance Method Details

#rollables(*models, opts) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rollable/base.rb', line 11

def rollables(*models, opts)
  # So we can access it in respond_to?
  @rollables = models.collect { |m| m.to_s.camelize }#Accepting symbols looks nicer than constants, so we need to convert them
  @role_names = opts[:roles] if opts.has_key?(:roles)

  if opts.has_key?(:allow_nil) && opts[:allow_nil]
    @rollables << nil
  end

  self.class_eval do
    # Hackety hack.
    class << self; attr_reader :rollables, :role_names; end;
  end
  
  set_target_model_helpers
  set_relations_on_rollables
  set_role_validations
  set_role_setter_helpers
end