Class: CafeCar::InputBuilder
- Inherits:
-
Object
- Object
- CafeCar::InputBuilder
- Defined in:
- lib/cafe_car/input_builder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
-
#initialize(method:, form:, **options, &block) ⇒ InputBuilder
constructor
A new instance of InputBuilder.
- #placeholder ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(method:, form:, **options, &block) ⇒ InputBuilder
Returns a new instance of InputBuilder.
7 8 9 10 11 12 |
# File 'lib/cafe_car/input_builder.rb', line 7 def initialize(method:, form:, **, &block) @method = method @form = form @options = @block = block end |
Instance Attribute Details
#as ⇒ Object (readonly)
Returns the value of attribute as.
3 4 5 |
# File 'lib/cafe_car/input_builder.rb', line 3 def as @as end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
3 4 5 |
# File 'lib/cafe_car/input_builder.rb', line 3 def form @form end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/cafe_car/input_builder.rb', line 3 def method @method end |
Instance Method Details
#placeholder ⇒ Object
20 21 22 23 |
# File 'lib/cafe_car/input_builder.rb', line 20 def placeholder I18n.t(method, scope: [ :helpers, :placeholder, object_name ], raise: true).presence rescue I18n::MissingTranslationData => _ end |
#type ⇒ Object
14 15 16 17 18 |
# File 'lib/cafe_car/input_builder.rb', line 14 def type @type ||= object.type_for_attribute(@method)&.type || reflect_on(method)&.macro end |