Module: LetMeIn

Defined in:
lib/letmein.rb

Defined Under Namespace

Modules: Model Classes: Config, Railtie, Session

Constant Summary collapse

Error =
Class.new StandardError

Class Method Summary collapse

Class Method Details

.accessor(name, index = 0) ⇒ Object



134
135
136
137
# File 'lib/letmein.rb', line 134

def self.accessor(name, index = 0)
  name = name.to_s.pluralize
  self.config.send(name)[index] || self.config.send(name)[0]
end

.configObject



125
126
127
# File 'lib/letmein.rb', line 125

def self.config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



129
130
131
# File 'lib/letmein.rb', line 129

def self.configure
  yield config
end

.initializeObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/letmein.rb', line 133

def self.initialize
  def self.accessor(name, index = 0)
    name = name.to_s.pluralize
    self.config.send(name)[index] || self.config.send(name)[0]
  end
  
  self.config.models.each do |model|
    klass = model.constantize rescue next
    klass.send :include, LetMeIn::Model
    
    session_model = "#{model.to_s.camelize}Session"
    
    # remove the constant if it's defined, so that we don't get spammed with warnings.
    Object.send(:remove_const, session_model) if (Object.const_get(session_model) rescue nil) 
    Object.const_set(session_model, Class.new(LetMeIn::Session))
  end
end