Class: CafeCar::Attributes
- Inherits:
-
Object
- Object
- CafeCar::Attributes
- Defined in:
- lib/cafe_car/attributes.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#permitted ⇒ Object
readonly
Returns the value of attribute permitted.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #editable ⇒ Object
- #info(method) ⇒ Object
-
#initialize(user, object, permitted_attributes) ⇒ Attributes
constructor
A new instance of Attributes.
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
#object ⇒ Object (readonly)
Returns the value of attribute object.
2 3 4 |
# File 'lib/cafe_car/attributes.rb', line 2 def object @object end |
#permitted ⇒ Object (readonly)
Returns the value of attribute permitted.
2 3 4 |
# File 'lib/cafe_car/attributes.rb', line 2 def permitted @permitted end |
#user ⇒ Object (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
#editable ⇒ Object
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:) |