Class: Statics::Model
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Statics::Model
- Defined in:
- lib/statics/model.rb
Defined Under Namespace
Modules: Types
Class Method Summary collapse
- .[](key) ⇒ Statics::Model
- .all ⇒ Statics::Collection
- .method_missing(method, *args, &block) ⇒ Object
- .respond_to_missing?(method, include_private = false) ⇒ Boolean
Class Method Details
.[](key) ⇒ Statics::Model
19 20 21 |
# File 'lib/statics/model.rb', line 19 def [](key) new(file_contents.fetch(key.to_s) { raise KeyNotFoundError }.merge(key: key.to_sym)) end |
.all ⇒ Statics::Collection
24 25 26 |
# File 'lib/statics/model.rb', line 24 def all @all ||= Collection.new(records) end |
.method_missing(method, *args, &block) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/statics/model.rb', line 28 def method_missing(method, *args, &block) if Collection.instance_methods.include?(method) all.public_send(method, *args, &block) else super end end |
.respond_to_missing?(method, include_private = false) ⇒ Boolean
36 37 38 |
# File 'lib/statics/model.rb', line 36 def respond_to_missing?(method, include_private = false) Collection.instance_methods(false).include?(method) || super end |