Class: CafeCar::Attributes

Inherits:
Object
  • Object
show all
Defined in:
lib/cafe_car/attributes.rb

Direct Known Subclasses

CafeCar::ApplicationPolicy::Attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, object, permitted_attributes) ⇒ Attributes

Returns a new instance of Attributes.



4
5
6
7
8
9
# File 'lib/cafe_car/attributes.rb', line 4

def initialize(user, object, permitted_attributes)
  @user      = user
  @object    = object
  @permitted = [ *permitted_attributes ]
  process_attributes!
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



2
3
4
# File 'lib/cafe_car/attributes.rb', line 2

def object
  @object
end

#permittedObject (readonly)

Returns the value of attribute permitted.



2
3
4
# File 'lib/cafe_car/attributes.rb', line 2

def permitted
  @permitted
end

#userObject (readonly)

Returns the value of attribute user.



2
3
4
# File 'lib/cafe_car/attributes.rb', line 2

def user
  @user
end

Instance Method Details

#editableObject



13
14
15
# File 'lib/cafe_car/attributes.rb', line 13

def editable
  @editable ||= @permitted.map()
end

#info(method) ⇒ Object



11
# File 'lib/cafe_car/attributes.rb', line 11

def info(method) = CafeCar[:FieldInfo].new(object:, method:)