Class: Transcriber::Resource::Key
- Inherits:
-
Object
- Object
- Transcriber::Resource::Key
- Defined in:
- lib/transcriber/resource/key.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#summarize ⇒ Object
Returns the value of attribute summarize.
Instance Method Summary collapse
- #convert_input_keys ⇒ Object
-
#initialize(name, options = {}) ⇒ Key
constructor
A new instance of Key.
- #input_path ⇒ Object
- #present?(resource) ⇒ Boolean
- #root_path? ⇒ Boolean
- #visible?(resource) ⇒ Boolean
Constructor Details
#initialize(name, options = {}) ⇒ Key
Returns a new instance of Key.
6 7 8 9 |
# File 'lib/transcriber/resource/key.rb', line 6 def initialize(name, = {}) @name = name @options = end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
4 5 6 |
# File 'lib/transcriber/resource/key.rb', line 4 def model @model end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/transcriber/resource/key.rb', line 4 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/transcriber/resource/key.rb', line 4 def @options end |
#summarize ⇒ Object
Returns the value of attribute summarize.
4 5 6 |
# File 'lib/transcriber/resource/key.rb', line 4 def summarize @summarize end |
Instance Method Details
#convert_input_keys ⇒ Object
11 12 13 14 |
# File 'lib/transcriber/resource/key.rb', line 11 def convert_input_keys .fetch(:convert_input_keys, model.try(:convert_input_keys) || Transcriber.configuration.convert_input_keys) end |
#input_path ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/transcriber/resource/key.rb', line 16 def input_path return @input_path.clone if @input_path @input_path = InputPath.resolve(, convert_input_keys) if @input_path.empty? and !root_path? @input_path = convert_input_keys.call([name]) end @input_path.clone end |
#present?(resource) ⇒ Boolean
33 34 35 |
# File 'lib/transcriber/resource/key.rb', line 33 def present?(resource) ![:if] ? true : resource.instance_eval(&[:if]) end |
#root_path? ⇒ Boolean
28 29 30 31 |
# File 'lib/transcriber/resource/key.rb', line 28 def root_path? path_definition = .slice(:start_key, :field) path_definition.any? and path_definition.first[1].empty? end |
#visible?(resource) ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/transcriber/resource/key.rb', line 37 def visible?(resource) !present?(resource) ? false : case visible = [:visible] when nil then true when Proc then resource.instance_eval(&visible) else visible end end |