Class: Noventius::Filter
- Inherits:
-
Object
- Object
- Noventius::Filter
- Defined in:
- lib/noventius/filter.rb
Constant Summary collapse
- RESERVED_ARGS =
%i(icon priority)
- DEFAULT_RESERVED_ARGS =
{ priority: 0 }
- TYPES =
%i(check_box color date datetime email month number phone radio_button range search select telephone text_area text url week)
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #deep_dup ⇒ Object
-
#initialize(name, type, dirty_args = {}) ⇒ Filter
constructor
A new instance of Filter.
- #to_js ⇒ Object
Constructor Details
#initialize(name, type, dirty_args = {}) ⇒ Filter
Returns a new instance of Filter.
12 13 14 15 16 17 18 19 |
# File 'lib/noventius/filter.rb', line 12 def initialize(name, type, dirty_args = {}) fail ArgumentError, "FilterType: [#{type}] not yet implemented." unless TYPES.include?(type.to_sym) @name = name.to_sym @type = type.to_sym @args = clean_args(dirty_args) @options = DEFAULT_RESERVED_ARGS.merge(reserved_args(dirty_args)) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/noventius/filter.rb', line 10 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/noventius/filter.rb', line 10 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/noventius/filter.rb', line 10 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/noventius/filter.rb', line 10 def type @type end |
Instance Method Details
#deep_dup ⇒ Object
30 31 32 |
# File 'lib/noventius/filter.rb', line 30 def deep_dup Marshal.load(Marshal.dump(self)) end |
#to_js ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/noventius/filter.rb', line 21 def to_js { "#{name}" => { type: type, options: } } end |