Class: Lanes::Screen::Definition
- Inherits:
-
Object
- Object
- Lanes::Screen::Definition
- Includes:
- Concerns::AttrAccessorWithDefault
- Defined in:
- lib/lanes/screen.rb
Instance Method Summary collapse
- #as_json ⇒ Object
- #group ⇒ Object
- #has_file_matching?(pattern) ⇒ Boolean
-
#initialize(id, extension_id) ⇒ Definition
constructor
A new instance of Definition.
- #model ⇒ Object
- #root_path ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(id, extension_id) ⇒ Definition
Returns a new instance of Definition.
93 94 95 96 97 |
# File 'lib/lanes/screen.rb', line 93 def initialize(id, extension_id) self.identifier = id @extension_id = extension_id @extension = extension_id.underscore.camelize end |
Instance Method Details
#as_json ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/lanes/screen.rb', line 118 def as_json { id: identifier, title: title, icon: icon, model: model_class, view: view_class, access: model_access, group_id: group_id, extension: extension, description: description, asset: asset } end |
#group ⇒ Object
99 100 101 |
# File 'lib/lanes/screen.rb', line 99 def group GROUPS[@group_id] end |
#has_file_matching?(pattern) ⇒ Boolean
103 104 105 |
# File 'lib/lanes/screen.rb', line 103 def has_file_matching?(pattern) Pathname.glob(root_path.join(pattern)).any? end |
#model ⇒ Object
113 114 115 116 |
# File 'lib/lanes/screen.rb', line 113 def model ext = Lanes::Extensions.for_identifier(@extension_id) (@extension_id.camelize + '::' + @model_class).constantize end |
#root_path ⇒ Object
107 108 109 110 111 |
# File 'lib/lanes/screen.rb', line 107 def root_path ext = Lanes::Extensions.for_identifier(@extension_id) raise "Unable to find extension '#{@extension_id}' for screen group" unless ext ext.root_path.join('client', url_prefix, identifier) end |
#to_json ⇒ Object
133 134 135 |
# File 'lib/lanes/screen.rb', line 133 def to_json Oj.dump(as_json, mode: :compat) end |