Class: Sapling::ActiveRecord

Inherits:
Base
  • Object
show all
Includes:
AdminAPI
Defined in:
lib/sapling/active_record.rb

Defined Under Namespace

Modules: AdminAPI

Instance Attribute Summary

Attributes inherited from Base

#controller

Instance Method Summary collapse

Methods included from AdminAPI

#activate_percentage, #activate_user, #deactivate_percentage, #deactivate_user

Methods inherited from Base

#active?, #active_features, #css_class, #css_class_prefix, #css_toggle_class, #initialize, #js_generator

Constructor Details

This class inherits a constructor from Sapling::Base

Instance Method Details

#featuresObject

returns hash of all features

keys are feature names (symbols)
values are:
  :percentage => nil or 0-100
  :user_ids => [] or array of user_ids (integers)


13
14
15
16
17
18
19
20
21
# File 'lib/sapling/active_record.rb', line 13

def features
  @features ||= ActiveRecordModel.find(:all).inject({}) do |ret,feature|
    name = feature.feature.to_sym
    ret[name]||=Feature.new(name)
    ret[name].percentage ||= feature.percentage
    ret[name].users[feature.user_id]=true if feature.user_id
    ret
  end
end

#reloadObject



23
24
25
26
# File 'lib/sapling/active_record.rb', line 23

def reload
  @features=nil
  true
end

#table_nameObject



4
5
6
# File 'lib/sapling/active_record.rb', line 4

def table_name
  ActiveRecordModel.table_name
end