Class: ActiveManageable::Base
- Inherits:
- 
      Object
      
        - Object
- ActiveManageable::Base
 
- Defined in:
- lib/active_manageable/base.rb
Instance Attribute Summary collapse
- 
  
    
      #attributes  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute attributes. 
- 
  
    
      #current_method  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute current_method. 
- 
  
    
      #options  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute options. 
- 
  
    
      #target  ⇒ Object 
    
    
      (also: #object, #collection)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute target. 
Class Method Summary collapse
- 
  
    
      .inherited(subclass)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Ruby method called when a child class inherits from a parent class. 
- 
  
    
      .manageable(*methods)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Include the required action methods in your class either all methods using the ActiveManageable::ALL_METHODS constant or selective methods from :index, :show, :new, :create, :edit, :update, :destroy and optionally set the :model_class. 
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
| 7 8 9 | # File 'lib/active_manageable/base.rb', line 7 def attributes @attributes end | 
#current_method ⇒ Object (readonly)
Returns the value of attribute current_method.
| 7 8 9 | # File 'lib/active_manageable/base.rb', line 7 def current_method @current_method end | 
#options ⇒ Object (readonly)
Returns the value of attribute options.
| 7 8 9 | # File 'lib/active_manageable/base.rb', line 7 def @options end | 
#target ⇒ Object (readonly) Also known as: object, collection
Returns the value of attribute target.
| 7 8 9 | # File 'lib/active_manageable/base.rb', line 7 def target @target end | 
Class Method Details
.inherited(subclass) ⇒ Object
Ruby method called when a child class inherits from a parent class
| 16 17 18 19 20 21 22 | # File 'lib/active_manageable/base.rb', line 16 def inherited(subclass) super # necessary to set default value here rather than in class_attribute declaration # otherwise all subclasses share the same hash/array instance subclass.defaults = {} subclass.module_initialize_state_methods = [] end | 
.manageable(*methods) ⇒ Object
Include the required action methods in your class either all methods using the ActiveManageable::ALL_METHODS constant or selective methods from :index, :show, :new, :create, :edit, :update, :destroy and optionally set the :model_class
For example:-
manageable ActiveManageable::ALL_METHODS
manageable ActiveManageable::ALL_METHODS, model_class: Album
manageable :index, :show
| 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # File 'lib/active_manageable/base.rb', line 35 def manageable(*methods) = methods..dup methods = ActiveManageable::Methods.constants if methods[0] == ActiveManageable::ALL_METHODS methods.each do |method| include ActiveManageable::Methods.const_get(method.to_s.classify) end include_search include_pagination .each { |key, value| send(:"#{key}=", value) } set_model_class end | 
Instance Method Details
#current_user ⇒ Object
| 99 100 101 | # File 'lib/active_manageable/base.rb', line 99 def current_user @current_user || ActiveManageable.current_user end | 
#with_current_user(user) ⇒ Object
| 103 104 105 106 107 108 | # File 'lib/active_manageable/base.rb', line 103 def with_current_user(user) @current_user = user yield ensure @current_user = nil end |